Partition, format, and mount a virtual hard disk to a folder...
[Root @ cncmail data1] # fdisk-L # check that there are several hard disks on the system.
Disk/dev/SDA: 36.4 GB, 36401479680 bytes
255 heads, 63 sectors/track, 4425 Cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Device boot start end blocks ID system
/Dev/sda1*1 255 2048256 83 Linux
/Dev/sda2 256 1530 10241437 + 83 Linux
/Dev/sda3 4296 4425 1044225 82 Linux swap
/Dev/sda4 1531 4295 22209862 + F Win95 ext 'd (LBA)
/Dev/sda5 1531 2805 10241406 83 Linux
/Dev/sda6 2806 4295 11968393 + 83 Linux
Partition Table entries are not in disk order
Disk/dev/sdb1: 10 Gb, 36703918080 bytes #/dev/sdb1 found here, with a capacity of 10 Gb, not partitioned. If there is no partition, follow the introduction in the previous article, add a virtual disk...
255 heads, 63 sectors/track, 4462 Cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Disk/dev/SDC doesn' t contain a valid Partition Table
[Root @ linux root] # fdisk/dev/sdb1 # Next, partition/dev/sdb1.
The number of cylinders for this disk is set to 4462.
There is nothing wrong with that, but this is larger than 1024,
And coshould in certain setups cause problems:
1) software that runs at boot time (e.g., old versions of lilo)
2) booting and partitioning software from other OSS
(E.g., DOS fdisk, OS/2 fdisk)
Command (M for help ):
M
Command action
A toggle a bootable flag
B edit BSD disklabel
C toggle the DOS compatibility flag
D delete a partition
L List known partition types
M print this menu
N Add a new partition
O create a new empty DOS partition table
P print the Partition Table
Q quit without saving changes
S create a new empty sun disklabel
T change a partition's System ID
U change display/entry units
V verify the Partition Table
W write table to disk and exit
X extra functionality (experts only)
Command (M for help ):
P
# Print the list of partitions under the current Hard Disk
Disk/dev/sdb1: 10 Gb, 36703918080 bytes
255 heads, 63 sectors/track, 4462 Cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Device boot start end blocks ID system
Command (M for help): N # Add a partition
Command action
E extended
P primary partition (1-4)
# Because primary partitions are usually selected, P is used here.
P
Partition Number (1-4): 1 # select 1 because it is the first partition. If it is the second partition, select 2, and so on.
First cylinder (1-4462, default 1): # Number of disks starting from the new partition
Using default value 1
Last cylinder or + size or + sizem or + sizek (1-4462, default 4462): # If you want to partition 10 Gb, enter + 10240 M, because all hard disk space is used here, the default value is used.
Using default value 4462
Command (M for help): p
Disk/dev/SDB: 10 Gb, 36703918080 bytes
255 heads, 63 sectors/track, 4462 Cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Device boot start end blocks ID system
/Dev/sdb1 1 4462 35840983 + 83 Linux
# The first partition has been split, and you have to write the partition to the hard disk.
Command (M for help): W
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Syncing disks.
The following job is to format the hard disk. I want to format it to ext3.
[Root @ linux root] #
Mkfs. ext3/dev/sdb1
Mke2fs 1.32 (09-nov-2002)
Filesystem label =
OS type: Linux
Block size = 4096 (log = 2)
Fragment size = 4096 (log = 2)
4480448 inodes, 8960245 Blocks
448012 blocks (5.00%) reserved for the Super User
First data block = 0
274 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
32768,983 04, 163840,229 376, 294912,819 200, 884736,160 5632, 2654208,
4096000,796 2624
Writing inode tables: Done
Creating Journal (8192 blocks): Done
Writing superblocks and filesystem accounting information: Done
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs-C or-I to override.
Check whether the format is good.
[Root @ linux root] #
Fdisk-l
Disk/dev/sda1: 10 Gb, 36401479680 bytes
255 heads, 63 sectors/track, 4425 Cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Device boot start end blocks ID system
/Dev/sda1*1 255 2048256 83 Linux
/Dev/sda2 256 1530 10241437 + 83 Linux
/Dev/sda3 4296 4425 1044225 82 Linux swap
/Dev/sda4 1531 4295 22209862 + F Win95 ext 'd (LBA)
/Dev/sda5 1531 2805 10241406 83 Linux
/Dev/sda6 2806 4295 11968393 + 83 Linux
Partition Table entries are not in disk order
Disk/dev/SDB: 36.7 GB, 36703918080 bytes
255 heads, 63 sectors/track, 4462 Cylinders
Units = cylinders of 16065*512 = 8225280 bytes
Device boot start end blocks ID system
/Dev/sdb1 1 4462 35840983 + 83 Linux
Attach virtual hard disk
Well differentiated and formatted. The following is the Mount
I mount/dev/sdb1 to/share. If it is mounted to an existing folder,Note: Make sure to back up the original folder !!! And then copy it in...
[Root @ linux root] # mkdir/share # first create the mounted directory data1
[Root @ linux root] # Mount/dev/sdb1/share # Mount sdb1 to data1
After the system is restarted, check whether the mounting is successful:
[Root @ Linux data1] # DF-H
File System capacity used available % mount point
/Dev/sda1 2.0g 454 M 1.4G 25%/
/Dev/sda6 12g 53 m 11g 1%/bak
/Dev/sdb1 34G 33 m 32G 1%/data1
None 250 m 0 250 m 0%/dev/SHM
/Dev/sda2 9.7G 1.5g 7.7g 17%/usr
/Dev/sda5 9.7g 8.6g 559 M 95%/var
Here we can see/dev/sda6 12g 53 m 11g 1%/bak
It indicates that the mounting is successful. You can view the mounted data1 under the root directory...
Done !!!