為虛擬機器新增硬碟並進行分割槽
如果你的Linux硬碟空間不足,那麼我們可以新增硬碟並且對其進行分割槽,下面是主要步驟:
1.首先,把虛擬機器中的系統關閉,如果現在不關閉的話,後面新增完硬碟還要重啟。然後選擇
虛擬機器》設定,在彈出的對話方塊中點選硬碟(SCSI),接著點選新增,就會出現新增硬體嚮導:硬碟》
SCSI(S)(推薦)》建立新虛擬磁碟》,設定磁碟大小,預設是20G。選擇將虛擬磁碟拆分成多個檔案。
2.開啟虛擬機器的Linux系統。執行fdisk -l:
[root@localhost ~]# fdisk -l
Disk /dev/sda: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 38 305203+ 83 Linux
/dev/sda2 39 12540 100422315 83 Linux
/dev/sda3 12541 13054 4128705 82 Linux swap / Solaris
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
可以看到此時多了個sdb,但是並沒有分割槽,下面我們為sdb進行分割槽:
輸入命令fdisk /dev/sdb,在提示下輸入m,就會出現以下列表,根據需要選擇選項完成自己的需要。輸入n,即為增加分割槽,接著輸入p建立主分割槽,再輸入1,下面會提示卷的起始地址和結束地址,回車預設就可以了。最後我們鍵入w儲存並退出。
[root@localhost /]# fdisk /dev/sdb
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 2610.
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)
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): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):
Using default value 2610
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
3.再次輸入命令fdisk -l就可以看到多了/dev/sdb1了,說明我們已經成功為sdb新增了分割槽。
[root@localhost /]# fdisk -l
Disk /dev/sda: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 38 305203+ 83 Linux
/dev/sda2 39 12540 100422315 83 Linux
/dev/sda3 12541 13054 4128705 82 Linux swap / Solaris
Disk /dev/sdb: 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/sdb1 1 2610 20964793+ 83 Linux
4.接著,對新建立的分割槽進行格式化,格式化成ext3的系統:
[root@localhost /]# mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2621440 inodes, 5241198 blocks
262059 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
160 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, 2654208,
4096000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
5.最後,我們就可以把/dev/sdb1掛載到新建的/u02目錄了:
[root@localhost /]# mount /dev/sdb1 /u02
[root@localhost /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 93G 18G 71G 21% /
/dev/sda1 289M 16M 259M 6% /boot
tmpfs 1014M 0 1014M 0% /dev/shm
/dev/scd0 23M 23M 0 100% /media/CDROM
/dev/scd1 2.8G 2.8G 0 100% /media/RHEL_5.4 i386 DVD
/dev/sdb1 20G 173M 19G 1% /u02
1.首先,把虛擬機器中的系統關閉,如果現在不關閉的話,後面新增完硬碟還要重啟。然後選擇
虛擬機器》設定,在彈出的對話方塊中點選硬碟(SCSI),接著點選新增,就會出現新增硬體嚮導:硬碟》
SCSI(S)(推薦)》建立新虛擬磁碟》,設定磁碟大小,預設是20G。選擇將虛擬磁碟拆分成多個檔案。
2.開啟虛擬機器的Linux系統。執行fdisk -l:
[root@localhost ~]# fdisk -l
Disk /dev/sda: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 38 305203+ 83 Linux
/dev/sda2 39 12540 100422315 83 Linux
/dev/sda3 12541 13054 4128705 82 Linux swap / Solaris
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
可以看到此時多了個sdb,但是並沒有分割槽,下面我們為sdb進行分割槽:
輸入命令fdisk /dev/sdb,在提示下輸入m,就會出現以下列表,根據需要選擇選項完成自己的需要。輸入n,即為增加分割槽,接著輸入p建立主分割槽,再輸入1,下面會提示卷的起始地址和結束地址,回車預設就可以了。最後我們鍵入w儲存並退出。
[root@localhost /]# fdisk /dev/sdb
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 2610.
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)
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): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):
Using default value 2610
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
3.再次輸入命令fdisk -l就可以看到多了/dev/sdb1了,說明我們已經成功為sdb新增了分割槽。
[root@localhost /]# fdisk -l
Disk /dev/sda: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 38 305203+ 83 Linux
/dev/sda2 39 12540 100422315 83 Linux
/dev/sda3 12541 13054 4128705 82 Linux swap / Solaris
Disk /dev/sdb: 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/sdb1 1 2610 20964793+ 83 Linux
4.接著,對新建立的分割槽進行格式化,格式化成ext3的系統:
[root@localhost /]# mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2621440 inodes, 5241198 blocks
262059 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
160 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, 2654208,
4096000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
5.最後,我們就可以把/dev/sdb1掛載到新建的/u02目錄了:
[root@localhost /]# mount /dev/sdb1 /u02
[root@localhost /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 93G 18G 71G 21% /
/dev/sda1 289M 16M 259M 6% /boot
tmpfs 1014M 0 1014M 0% /dev/shm
/dev/scd0 23M 23M 0 100% /media/CDROM
/dev/scd1 2.8G 2.8G 0 100% /media/RHEL_5.4 i386 DVD
/dev/sdb1 20G 173M 19G 1% /u02
6.掛載成功之後,會在本次系統啟動過程中生效,如果下次系統重啟了,那麼就會失去這次的掛載。
想要每次啟動系統都自動掛載,可以在/etc/fstab檔案中加入如下一行內容:
/dev/sdb1 /u02 ext3 defaults 0 0
那麼就可以保證即使系統重新啟動/dev/sdb1也會自動掛載
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29800581/viewspace-1270511/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 為linux新增一塊新硬碟並分割槽Linux硬碟
- 虛擬機器Unbuntu如何修改硬碟空間大小(不需要分割槽)虛擬機硬碟
- linux掛載新硬碟並進行分割槽格式化Linux硬碟
- Liunx新增新硬碟和分割槽方法硬碟
- DiskGenius分割槽行動硬碟硬碟
- 如何給VirtualBox虛擬機器的ubuntu LVM分割槽擴容虛擬機UbuntuLVM
- win10新增硬碟分割槽怎麼操作 win10硬碟如何增加新分割槽Win10硬碟
- 虛擬機器硬碟vmdk壓縮瘦身並掛載到VirtualBox虛擬機硬碟
- 虛擬機器Ubuntu 掛載硬碟虛擬機Ubuntu硬碟
- linux硬碟分割槽Linux硬碟
- VMware Workstation Pro虛擬機器配置Linux系統系統分割槽配置虛擬機Linux
- Linux下進行格式化行動硬碟(U盤)以及分割槽Linux硬碟
- 重要 | Spark分割槽並行度決定機制Spark並行
- Virtualbox中Linux新增新磁碟並建立分割槽Linux
- mysql 進行表分割槽MySql
- windows下vmware虛擬機器擴充硬碟Windows虛擬機硬碟
- DIY攢機-購買新硬碟後為什麼要分割槽?硬碟
- SSD固態硬碟要分割槽嗎?SSD固態硬碟分割槽與不分割槽的效能對比硬碟
- PostgreSQL 並行vacuum patch - 暨為什麼需要並行vacuum或分割槽表SQL並行
- linux之硬碟分割槽管理Linux硬碟
- KVM虛擬機器新增物理網路卡虛擬機
- ghost win10如何分割槽硬碟_ghost win10怎麼分割槽硬碟Win10硬碟
- Windows2008R2新新增的硬碟無法識別 VM虛擬機器Windows硬碟虛擬機
- Dalvik虛擬機器、Java虛擬機器與ART虛擬機器虛擬機Java
- [LINUX] Arch Linux 硬碟拷貝式裝系統+新增 home 分割槽Linux硬碟
- ubuntu虛擬機器克隆後需要進行的修改Ubuntu虛擬機
- 如何在windows下進行LINUX虛擬機器搭建WindowsLinux虛擬機
- win10系統硬碟如何分割槽_win10主硬碟怎麼分割槽Win10硬碟
- 電腦硬碟分割槽要注意什麼,刪除硬碟分割槽的注意事項硬碟
- 5分鐘學會,同時對100+臺linux虛擬機器進行批量操作命令,例如:磁碟分割槽、掛載目錄、修改linux虛擬機器最大連線數等;只要你需要,都能執行Linux虛擬機
- Linux系統如何進行分割槽?swap分割槽是什麼?Linux
- DIY攢機-你真的搞懂了硬碟分割槽嗎?硬碟
- Linux硬碟分割槽及開機自動掛載Linux硬碟
- 胖爪裝機大師pe硬碟分割槽教程硬碟
- Linux 新增LVM分割槽及LVM分割槽擴容LinuxLVM
- MySql資料分割槽操作之新增分割槽操作MySql
- 虛擬化實戰:對(類)虛擬機器進行實時熱遷移虛擬機
- 伺服器物理機使用ESXI虛擬化並劃分虛擬機器伺服器虛擬機
- VM虛擬機器 linux系統新增磁碟虛擬機Linux