VirtualBox adding new disks and creating partitions in Linux

Source: Internet
Author: User

Original: https://www.linuxidc.com/Linux/2017-01/139616.htm

------------------------------------------------------------------

Introduction: We often use the system when suddenly found, hey yo ~ ~ ~ Our disk space is not enough! I met the common is the database data explosion, reserved space No, had to new add disk, in VB virtual machine can be realized, often suffer from no good pictures and illustrations, the following I come for everyone simple and quick demonstration of the actual operation, do a "real operation clan" even yes!

VirtualBox in Linux Add a new disk, create partition--format-mount partition.

One VirtualBox setting add disk

Shut down your virtual machine, mount the new disk can not be in the boot state do virtualbox menu bar--------storage----------Right click, select "Add virtual hard disk" Note: Do not select "IDE controller" This is a very old and very ancient disk, Now that it has been eliminated, please select the SATA controller is now popular serial-port disk added. We click the "Add Virtual Disk" button in the Red box

It will ask you whether the add virtual disk is to create a new file to save the data, or to select an existing file to save, we select "Create a new virtual disk"

Then let you choose "Virtual Disk File type", please note that 90% is the choice of VDI (Virtual disk image) type, if your system does not have any special needs, please select the first one. Click "Next"

Select "Allocate dynamically" disk space, expand the physical disk space only when needed, click "Next"

Path to Virtual disk image file: E:\Vritaulbox\leonarding2.vdi

Size of Virtual disk image file: 20GB

Click "Create" now has created a new virtual disk "Leonarding2.vdi", we start the system, VirtualBox Add work has been completed, the rest is on the Linux system to the newly added disk---partition.

Two Linux systems for new disk partitioning

[[Email protected]~]# fdisk–l Check existing system disk space

disk/dev/sda:21.4 GB, 21474836480 bytes This is our original old disk.

255 heads, 63sectors/track, 2610 cylinders

Units = cylindersof 16065 * = 8225280 bytes

Device Boot Start End Blocks Id System old disk is divided by 2 partitions

/DEV/SDA1 * 1 104391 Linux

/dev/sda2 2610 20860402+ 8e Linux LVM

disk/dev/sdb:21.4 GB, 21474836480 bytes This is our newly added disk/dev/sdb, not yet partitioned

255 heads, 63sectors/track, 2610 cylinders

Units = cylindersof 16065 * = 8225280 bytes

DISK/DEV/SDBDOESN ' t contain a valid partition table does not contain valid partition table information, we need to create a partitioned table for the new disk

disk/dev/dm-0:18.2 GB, 18253611008 bytes The bottom of this is no tube.

255 heads, 63sectors/track, 2219 cylinders

Units = cylindersof 16065 * = 8225280 bytes

DISK/DEV/DM-0DOESN ' t contain a valid partition table

disk/dev/dm-1:3087 MB, 3087007744 bytes

255 heads, 63sectors/track, 375 cylinders

Units = cylindersof 16065 * = 8225280 bytes

DISK/DEV/DM-1DOESN ' t contain a valid partition table

[[Email protected]~]# fdisk/dev/sdb SDB disk partition, there are many options, we choose M Help info

Device Containsneither A valid DOS partition table, nor Sun, SGI or OSF Disklabel

Building a new Dosdisklabel. Changes'll remain in memory only,

Until you decideto write them. After that, of course, the previous

Content won ' t be recoverable.

The number ofcylinders for this disk was set to 2610.

There is nothingwrong with a, but the is larger than 1024,

And could incertain setups cause problems with:

1) software Thatruns at boot time (e.g., old versions of LILO)

2) booting andpartitioning software from other OSs

(e.g., DOS fdisk, OS/2 fdisk)

Warning:invalidflag 0x0000 of partition Table 4 would be a corrected by W (rite)

Command (M forhelp): M select m to see Help information

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 create a fresh 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 forhelp): n Create a new partition

Command Action

E Extended

P primary partition (1-4)

P Select p to add primary partition

Partition number (1-4): 1 Select the primary partition numbers 1 so that the primary partition after creation is SDB1

First cylinder (1-2610, default 1): Select a formatted partition starting with the first few bars

Using DefaultValue 1 Direct "enter" by default starting from 1th cylinder

Last cylinder or+size or +sizem or +sizek (1-2610, default 2610): Select Format Partition end from the first few bars

Using defaultvalue 2610 Direct "Enter" by default from the last 1 cylinders end

We've formatted all 20GB spaces as a partition, and if a friend wants to divide multiple partitions, here's how

Last cylinder or+size or +sizem or +sizek (1-2610, default 2610): Enter the size you want in megabytes

This way we create a partition, and if you want to create more partitions, you can continue with the steps above.

Command (M Forhelp): W type W, save settings and exit, complete new disk partition table creation

The partitiontable has been altered!

Calling IOCTL () tore-read partition table.

Syncing disks.

[Email protected]~]# fdisk–l We're looking at the system disk space allocation

disk/dev/sda:21.4 GB, 21474836480 bytes

255 heads, 63sectors/track, 2610 cylinders

Units = cylindersof 16065 * = 8225280 bytes

Device Boot Start End Blocks Id System

/DEV/SDA1 * 1 104391 Linux

/dev/sda2 2610 20860402+ 8e Linux LVM

disk/dev/sdb:21.4 GB, 21474836480 bytes Then we can see that the new disk has been added to the partition table.

255heads, Sectors/track, 2610 cylinders

Units =cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

/DEV/SDB1 1 2610 20964793+ Linux

Here we format the/DEV/SDB1 partition for the new disk

[[Email protected]~]# mkfs-t ext4/dev/sdb1 format/DEV/SDB1 partition in EXT4 format

Mke4fs 1.41.12 (17-may-2010)

Filesystem label=

OS type:linux OS type Linux

Block size=4096 (log=2) OS chunk size 4k

Fragment size=4096 (log=2)

Stride=0 Blocks,stripe width=0 Blocks

1310720 inodes,5241198 Blocks

262059 blocks (5.00%) reserved for the Super user

First Data block=0

Maximum filesystemblocks=4294967296

Block groups

32768 blocks Pergroup, 32768 fragments per group

8192 inodes Pergroup

Superblock backupsstored on blocks:

32768, 98304, 163840, 229376, 294912,819200, 884736, 1605632, 2654208,

4096000

Writing Inodetables:done

Creating Journal (32768 blocks): Done

Writingsuperblocks and filesystem Accounting Information:done

This filesystemwill is automatically checked every mounts or

Days,whichever comes first. Use Tune4fs-c or-i to override.

To this our new partition has been formatted, the following we will be mounted on the partition can be used!

[[Email protected]~]# df–h This is the mount point distribution before we mount the new partition

Filesystem Size used Avail use% mounted on

/dev/mapper/volgroup00-logvol00

17G 15G 1.6G 90%/

/DEV/SDA1 99M 23M 71M 25%/boot

Tmpfs 731M 320M 411M 44%/DEV/SHM

/dev/sr0 55M 55M 0 100%/media/vboxadditions_4.2.6_82870

[[Email protected]/]# mkdir/u02 Create a new mount directory on the root directory/u02

[[Email protected]/]# mount/dev/sdb1/u02 to mount the new disk partition to the/U02 directory

[Email protected]/]# df–h This is the mount point distribution after we mount the new partition

Filesystem Size used Avail use% mounted on

/dev/mapper/volgroup00-logvol00

17G 15G 1.6G 90%/

/DEV/SDA1 99M 23M 71M 25%/boot

Tmpfs 731M 320M 411M 44%/DEV/SHM

/dev/sr0 55M 55M 0 100%/media/vboxadditions_4.2.6_82870

/DEV/SDB1 20G 172M 19G 1%/u02

Now we can use the newly added disk space as normal.

[[Email protected]/]# cd/u02

[[Email protected]]# mkdir app create an app directory try

[Email protected]]# ll

Total 20

Drwxr-xr-x 2 rootroot 4096 Apr 09:12 app OK successfully created wood problem

DRWX------2 rootroot 16384 Apr 08:59 lost+found

To this VirtualBox Linux add a new disk--create partition---format-mount Partition series operation complete

Virtualbox add disk create partition format mount partition

Auto-mount new disk partition on boot/DEV/SDB1

[[email protected]/]# Vim/etc/fstab Modify the file and add a new line at the end of the file

/DEV/VOLGROUP00/LOGVOL00/EXT3 Defaults 1 1

Label=/boot/boot ext3 Defaults 1 2

TMPFS/DEV/SHM TMPFS Defaults 0 0

Devpts/dev/pts devpts gid=5,mode=620 0 0

Sysfs/sys Sysfs Defaults 0 0

PROC/PROC proc Defaults 0 0

/DEV/VOLGROUP00/LOGVOL01 swap swap defaults 0 0

/DEV/SDB1/U02 EXT4 Defaults 0 0

This will automatically mount to the/u02 directory after rebooting the system.

VirtualBox adding new disks and creating partitions in Linux

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.