為虛擬機器新增硬碟並進行分割槽
如果你的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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 虛擬塊硬碟,新增點swap分割槽空間(轉)硬碟
- 為linux新增一塊新硬碟並分割槽Linux硬碟
- 轉:虛擬機器中為Linux新增硬碟虛擬機Linux硬碟
- 虛擬機器Unbuntu如何修改硬碟空間大小(不需要分割槽)虛擬機硬碟
- 擴充套件Linux虛擬機器硬碟、分割槽一例薦套件Linux虛擬機硬碟
- java虛擬機器執行時記憶體分割槽Java虛擬機記憶體
- 虛擬機器增加磁碟分割槽的大小虛擬機
- linux 新增硬碟分割槽Linux硬碟
- 建立Azure DS 虛擬機器並附加SSD硬碟虛擬機硬碟
- linux掛載新硬碟並進行分割槽格式化Linux硬碟
- Liunx新增新硬碟和分割槽方法硬碟
- vmware虛擬機器調整ubuntu10.04分割槽大小虛擬機Ubuntu
- DiskGenius分割槽行動硬碟硬碟
- 虛擬機器Ubuntu 掛載硬碟虛擬機Ubuntu硬碟
- win10新增硬碟分割槽怎麼操作 win10硬碟如何增加新分割槽Win10硬碟
- 虛擬機器硬碟vmdk壓縮瘦身並掛載到VirtualBox虛擬機硬碟
- vm虛擬機器改變硬碟大小虛擬機硬碟
- 如何給VirtualBox虛擬機器的ubuntu LVM分割槽擴容虛擬機UbuntuLVM
- Xen虛擬機器新增網路卡虛擬機
- 為VMware增加虛擬硬碟硬碟
- VMware Workstation Pro虛擬機器配置Linux系統系統分割槽配置虛擬機Linux
- Linux下新增新硬碟,分割槽及掛載Linux硬碟
- windows下vmware虛擬機器擴充硬碟Windows虛擬機硬碟
- 重要 | Spark分割槽並行度決定機制Spark並行
- 《RHEL6硬碟的分割槽和swap分割槽管理》——硬碟分割槽的大總結硬碟
- vmware12下對虛擬機器ubuntu14.10系統所在分割槽sda1進行磁碟擴容虛擬機Ubuntu
- 分割槽索引的並行度索引並行
- 分割槽表並行建立索引並行索引
- VirtualBox虛擬機器新增共享磁碟虛擬機
- KVM虛擬機器新增物理網路卡虛擬機
- Linux下進行格式化行動硬碟(U盤)以及分割槽Linux硬碟
- mysql 進行表分割槽MySql
- DIY攢機-購買新硬碟後為什麼要分割槽?硬碟
- linux硬碟分割槽Linux硬碟
- Linux下新增硬碟,分割槽,格式化詳解Linux硬碟
- ubuntu虛擬機器克隆後需要進行的修改Ubuntu虛擬機
- 【小貼士】RedHat虛擬機器mount新硬碟Redhat虛擬機硬碟
- PostgreSQL 並行vacuum patch - 暨為什麼需要並行vacuum或分割槽表SQL並行