Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add a new disk to Linux in Virtualbox

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In Virtualbox Linux how to add a new disk, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

Introduction: when we are using the system, we suddenly find that we don't have enough disk space! I encountered a common database data explosion, there is no space reserved, so I have no choice but to add a new disk, which can be realized on the VB virtual machine, often suffering from the lack of good information with both pictures and texts. Here I will show you a simple and quick demonstration of how to be an "operator family".

One virtualbox setting to add disk

Shut down your virtual machine and mount the new disk cannot be done in the boot state.

Virtualbox menu bar-> Settings-> Storage-> SATA Controller-> right-click, select "add Virtual hard disk"

Note: do not choose "IDE controller" this is a very old parallel port disk, now all have been eliminated, please choose SATA controller now popular serial port disk to add. We click the "add virtual disk" button in the red box

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

At this time, you are asked to choose "virtual disk file type". Please note that 90% of them are VDI (virtual disk image). If your system does not have any special needs, please choose the first one. Click "next"

Select "dynamically allocate" disk space, expand physical disk space only when needed, and click next.

Path to the virtual disk image file: e:\ Vritaulbox\ leonarding2.vdi

Size of the virtual disk image file: 20GB

Click "create"

Now that we have created a new virtual disk "leonarding2.vdi", we have started the system, the virtualbox addition has been completed, and all that is left is the newly added disk-> partition in the Linux system.

Second, Linux system for new disk partitioning

[root@leonarding1~] # fdisk-l check existing system disk space

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

255 heads, 63sectors/track, 2610 cylinders

Units = cylindersof 16065 * 512 = 8225280 bytes

The old Device Boot Start End Blocks Id System disk is divided into two partitions.

/ dev/sda1 * 1 13 104391 83 Linux

/ dev/sda2 14 2610 20860402 + 8e Linux LVM

Disk/dev/sdb: 21.4GB, 21474836480 bytes this is our newly added disk / dev/sdb, there is no partition yet

255 heads, 63sectors/track, 2610 cylinders

Units = cylindersof 16065 * 512 = 8225280 bytes

Disk / dev/sdbdoesn't contain a valid partition table does not contain valid partition table information, we need to create a partition table for the new disk

Disk / dev/dm-0:18.2 GB, 18253611008 bytes, don't worry about the following

255 heads, 63sectors/track, 2219 cylinders

Units = cylindersof 16065 * 512 = 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 * 512 = 8225280 bytes

Disk / dev/dm-1doesn't contain a valid partition table

[root@leonarding1~] # fdisk / dev/sdb sdb disk partition, there are many options, we choose m help information

Device containsneither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOSdisklabel. Changes will 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 is set to 2610.

There is nothingwrong with that, but this 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 will be corrected by w (rite)

Command (m forhelp): M Select m to see the 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 creates 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 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 number 1, so that the created primary partition is sdb1

First cylinder (1-2610, default 1): select a formatted partition from which cylinder to start

Using defaultvalue 1 direct "enter" starts from the first cylinder by default.

Last cylinder or+size or+ sizeM or+ sizeK (1-2610, default 2610): select the cylinder from which to end the formatted partition

Using defaultvalue 2610 direct "enter" ends with the last cylinder by default.

We have formatted all the 20GB spaces into one partition. If a friend wants to divide multiple partitions, do the following

Last cylinder or+size or+ sizeM or+ sizeK (1-2610, default 2610): enter the size you want in MB.

In this way, we have finished creating a partition, and if you want to create more partitions, you can continue to create them as described above.

Command (m forhelp): W type w, save the settings and exit, and complete the creation of the new disk partition table

The partitiontable has been altered!

Calling ioctl () tore-read partition table.

Syncing disks.

[root@leonarding1~] # fdisk-l Let's take a look at the disk space allocation of the system

Disk / dev/sda:21.4 GB, 21474836480 bytes

255 heads, 63sectors/track, 2610 cylinders

Units = cylindersof 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/ dev/sda1 * 1 13 104391 83 Linux

/ dev/sda2 14 2610 20860402 + 8e Linux LVM

Disk/dev/sdb: 21.4 GB, 21474836480 bytes at this time we can see that the new disk has been added to the partition table

255heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/ dev/sdb1 1 2610 20964793 + 83 Linux

Let's format the / dev/sdb1 partition of the new disk

[root@leonarding1~] # mkfs-t ext4 / dev/sdb1 formats the / dev/sdb1 partition in ext4 format

Mke4fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux operating system type Linux

Block size=4096 (log=2) operating system block 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

160 block groups

32768 blocks pergroup, 32768 fragments pergroup

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 be automatically checked every 35 mounts or

180 days,whichever comes first. Use tune4fs-c or-i to override.

At this point, our new partition has been formatted, now we will mount the partition and we can use it!

[root@leonarding1~] # 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

[root@leonarding1/] # mkdir / U02 create a new mount directory / U02 on the root directory

[root@leonarding1/] # mount / dev/sdb1 / U02 Mount the new disk partition to the / U02 directory

[root@leonarding1/] # 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 normally.

[root@leonarding1/] # cd / u02

[root@leonarding1u02] # mkdir app try to create an app directory

[root@leonarding1u02] # ll

Total 20

Drwxr-xr-x 2 rootroot 4096 Apr 14 09:12 app ok successfully created no problem

Drwx- 2 rootroot 16384 Apr 14 08:59 lost+found

Linux add a new disk to this Virtualbox-> create partition-> format-> mount partition series operation completed

Virtualbox add disk create partition format mount partition

Boot automatically mounts new disk partitions / dev/sdb1

[root@leonarding1 /] # 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 00

/ dev/sdb1 / u02 ext4 defaults 0 0

In this way, it will be automatically mounted to the / u02 directory after restarting the system.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report