In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "the method of adding hard disk to linux virtual machine". In the daily operation, I believe that many people have doubts about the method of adding hard disk to linux virtual machine. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to add hard disk to linux virtual machine". Next, please follow the editor to study!
I. hard disk identification of Linux
After 2.6kernel, linux will create the corresponding device file under / dev/ for the identified hardware devices. Such as:
Sda represents the first SCSI hard drive.
Hda represents the first IDE hard disk (that is, connected to the Master port of the first IDE interface).
Scd0 represents the first USB CD-ROM drive.
When a new hard drive is added, the corresponding device files are generated in the / dev directory. Cciss's hard disk is an exception, its
The device file is in the / dev/cciss/ directory. Generally, you can use the "fdisk-l" command to list the hard drives currently connected to the system.
Device and partition information. If there is no partition information for the new hard disk, only the hard disk size information is displayed.
two。 Add a new hard drive to the linux system
As explained below, on GTES 11, add a 10 G hard disk to the Slave interface of * IDE ports.
After installing the hard drive, boot into Turbolinux. Log in as root.
Execute the fdisk-l command to display the hard disk device of the current system.
[root@g11-64-1 ~] # fdisk-l
Disk / dev/hda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/hda1 * 1 13 104391 83 Linux
/ dev/hda2 14 89 610470 82 Linux swap / Solaris
/ dev/hda3 90 2610 20249932 + 83 Linux
Disk / dev/hdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk / dev/hdb doesn't contain a valid partition table
[root@g11-64-1] #
Shows that the hdb has no partition information and the size is 10G.
Use the fdisk command to partition hdb.
[root@g11-64-1 ~] # fdisk / dev/hdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only
Until you decide to write them. After that, of course, the previous
Content won't be recoverable.
The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024
And could in certain setups cause problems with:
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w (rite)
Enter: n for new partition.
Command (m for help): n
Command action
E extended
P primary partition (1-4)
Enter: P to create an original partition.
P
Partition number (1-4): 1
Enter: 1 indicates that the partition number is 1.
First cylinder (1-1305, default 1):
Enter: enter indicates that the default starting cylinder number is used.
Using default value 1
Last cylinder or + size or + sizeM or + sizeK (1-1305, default 1305):
Enter: enter indicates that the default ending column number is used. That is, this partition uses the entire hard disk space.
Using default value 1305
Command (m for help): W
Enter: W save disk, exit fdisk.
The partition table has been altered!
Calling ioctl () to re-read partition table.
Syncing disks.
Then use the fdisk-l command to check the partition.
[root@g11-64-1 ~] # fdisk-l
Disk / dev/hda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/hda1 * 1 13 104391 83 Linux
/ dev/hda2 14 89 610470 82 Linux swap / Solaris
/ dev/hda3 90 2610 20249932 + 83 Linux
Disk / dev/hdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/hdb1 1 1305 10482381 83 Linux
Shows that there is a hdb1 partition on / dev/hdb, which is in linux format.
After the partition, the partition needs to be formatted.
[root@g11-64-1 ~] # mkfs.ext3 / dev/hdb1
Mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1310720 inodes, 2620595 blocks
131029 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs-c or-i to override.
Hang the new partition on / mnt/hdb1.
[root@g11-64-1 ~] # mkdir / mnt/hdb1
[root@g11-64-1] # mount / dev/hdb1 / mnt/hdb1
[root@g11-64-1 ~] # df-h
Filesystem Size Used Avail Use% Mounted on
/ dev/hda3 19G 8.2G 9.7G 46% /
/ dev/hda1 99M 16M 79M 17% / boot
Tmpfs 250m 0 250m 0% / dev/shm
/ dev/hdb1 9.9G 151m 9.2G 2% / mnt/hdb1
[root@g11-64-1] #
Hdb1 has been mounted on / mnt/hdb1, and the remaining space is 9.2G.
Create a file on this partition.
[root@g11-64-1 ~] # cd / mnt/hdb1
[root@g11-64-1 hdb1] # ls > a
[root@g11-64-1 hdb1] # ls-hl
Total 20K
-rw-r--r-- 1 root root 13 Nov 3 08:45 a
Drwx- 2 root root 16K Nov 3 08:44 lost+found
[root@g11-64-1 hdb1] #
Uninstall the hdb1 partition.
[root@g11-64-1 hdb1] # cd
[root@g11-64-1 ~] # umount / mnt/hdb1
[root@g11-64-1 ~] # df-h
Filesystem Size Used Avail Use% Mounted on
/ dev/hda3 19G 8.2G 9.7G 46% /
/ dev/hda1 99M 16M 79M 17% / boot
Tmpfs 250m 0 250m 0% / dev/shm
[root@g11-64-1] #
three。 Set up a new hard disk to boot and mount automatically
Add the mount information of the new hard disk to / etc/fstab. Add the following line:
/ dev/hdb1 / mnt/hdb1 ext3 defaults 1 2
In this way, after each boot, the system will automatically mount / dev/hdb1 to / mnt/hdb1.
At this point, the study on "the method of adding hard disk to linux virtual machine" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.