[Linux] adding a new disk to a vbox VM

Source: Internet
Author: User

[Linux] adding a new disk to a vbox VM

This is the case. The hard disk setting was too small when I started creating a virtual machine. It was only 10 Gb. Now I have added a hard disk to this linux (centos6.6) virtual machine through vbox settings.
The following is how to mount the hard disk to the system.

Use fdisk to view information about the current physical disk (only root permission is required)

All of the following operations are root permissions.

[root@orangleliu ~]# fdisk -l...Disk /dev/sdb: 32.2 GB, 32212254720 bytes255 heads, 63 sectors/track, 3916 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000...
Write Partition Table

The following is an interaction process. After each input, enter

[root@orangleliu ~]# fdisk /dev/sdbDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0xa4378777.Changes will remain in memory only, until you decide to write them.After that, of course, the previous content won't be recoverable.Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u').Command (m for help): nCommand action e extended p primary partition (1-4)pPartition number (1-4): 1First cylinder (1-3916, default 1):Using default value 1Last cylinder, +cylinders or +size{K,M,G} (1-3916, default 3916):Using default value 3916Command (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.

After the operation, let's check the disk information.

# fdisk -l...Disk /dev/sdb: 32.2 GB, 32212254720 bytes255 heads, 63 sectors/track, 3916 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xa4378777 Device Boot Start End Blocks Id System/dev/sdb1 1 3916 31455238+ 83 Linux...

A partition is added.

Format partitions

One command is enough.

# mkfs.ext4 /dev/sdb1mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks1966080 inodes, 7863809 blocks393190 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=4294967296240 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000?Writing inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 26 mounts or180 days, whichever comes first. Use tune2fs -c or -i to override.
Create a new volume label (ignore)

In this step, I saw some people did it, and some did not, so I checked the information.
See the e2label command.
You can skip this operation.

# e2label /dev/sdb1 /data

Check

# e2label /dev/sdb1/data
Mount

Create a mount Directory, which is consistent with the previous step.

mkdir /data

To enable automatic mounting, you also need to edit the/etc/fstab file and add a line after the file.

/dev/sdb1 /data ext4 defaults 0 0

Some may be unfamiliar with this configuration file, see [fatab explanation] (https://wiki.archlinux.org/index.php/Fstab_ (% E7 % AE % 80% E4 % BD % 93% E4 % B8 % AD % E6 % 96% 87)

Test
# mount -a# df -lhFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg_orangleliu-lv_root 6.5G 3.2G 3.0G 52% /tmpfs 499M 0 499M 0% /dev/shm/dev/sda1 477M 29M 424M 7% /boot/dev/sdb1 30G 44M 28G 1% /data

Restart the instance and check the mounting status again. The mounting is successful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.