suse linux增加新磁盘分区,Virtualbox中Linux添加新磁盘并创建分区
引言:我們常常在使用系統(tǒng)的時(shí)候突然發(fā)現(xiàn),哎呦~~~我們的磁盤空間不夠用啦!我遇到常見的就是數(shù)據(jù)庫數(shù)據(jù)暴增,預(yù)留的空間沒有啦,只好新添加磁盤,在VB虛擬機(jī)上就可以實(shí)現(xiàn),往往苦于沒有圖文并茂的好資料,下面我來為大家簡單快捷的實(shí)操示范一下,做一名“實(shí)操族”偶耶!
Virtualbox中Linux添加一個(gè)新磁盤->創(chuàng)建分區(qū)->格式化->掛載分區(qū)。
一virtualbox設(shè)置添加磁盤
關(guān)閉你的虛擬機(jī),掛載新磁盤不可以在開機(jī)狀態(tài)做
Virtualbox菜單欄->設(shè)置->存儲(chǔ)-> SATA控制器->右擊,選擇“添加虛擬硬盤”
注:千萬不要選擇“IDE控制器”這是一種非常古老的并口磁盤,現(xiàn)在已經(jīng)都淘汰了,請(qǐng)選SATA控制器現(xiàn)在流行的串口磁盤添加。我們點(diǎn)擊紅框框中的“添加虛擬磁盤”按鈕
它會(huì)問你,添加虛擬磁盤是要?jiǎng)?chuàng)建一個(gè)新文件來保存數(shù)據(jù),還是選擇一個(gè)現(xiàn)有文件保存,我們選擇“創(chuàng)建新的虛擬磁盤”
這時(shí)又讓你選擇“虛擬磁盤文件類型”,請(qǐng)注意90%都是選擇VDI(虛擬磁盤映像)類型的,如果你的系統(tǒng)沒有什么特殊需求,請(qǐng)選擇第一個(gè)。點(diǎn)擊“下一步”
選擇“動(dòng)態(tài)分配”磁盤空間,只在需要的時(shí)候擴(kuò)展物理磁盤空間,點(diǎn)擊“下一步”
虛擬磁盤映像文件的路徑:E:\Vritaulbox\leonarding2.vdi
虛擬磁盤映像文件的大小:20GB
點(diǎn)擊“創(chuàng)建”
現(xiàn)在已經(jīng)創(chuàng)建好了一個(gè)新的虛擬磁盤“l(fā)eonarding2.vdi”,我們啟動(dòng)系統(tǒng),virtualbox添加工作已經(jīng)完成,剩下的就是在Linux系統(tǒng)中給新添加的磁盤->分區(qū)。
二Linux系統(tǒng)進(jìn)行新磁盤分區(qū)
[root@leonarding1~]# fdisk –l檢查現(xiàn)有系統(tǒng)磁盤空間
Disk/dev/sda: 21.4 GB, 21474836480 bytes這是我們?cè)瓉淼哪菈K舊磁盤
255 heads, 63sectors/track, 2610 cylinders
Units = cylindersof 16065 * 512 = 8225280 bytes
Device Boot? ? ?Start? ? ? ?End? ? ?Blocks? Id? System舊磁盤就分了2個(gè)分區(qū)
/dev/sda1? ?*? ? ? ? 1? ? ? ? 13? ? ?104391? ?83? Linux
/dev/sda2? ? ? ? ? ?14? ? ? ?2610? ?20860402+? 8e? Linux LVM
Disk/dev/sdb: 21.4 GB, 21474836480 bytes這是我們新添加的磁盤/dev/sdb,還沒有分區(qū)
255 heads, 63sectors/track, 2610 cylinders
Units = cylindersof 16065 * 512 = 8225280 bytes
Disk /dev/sdbdoesn't contain a valid partition table不包含有效分區(qū)表信息,我們需要給新磁盤創(chuàng)建分區(qū)表
Disk /dev/dm-0:18.2 GB, 18253611008 bytes下面這些都不用管
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磁盤分區(qū),有很多選項(xiàng),我們選擇m幫助信息
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選擇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創(chuàng)建一個(gè)新分區(qū)
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創(chuàng)建一個(gè)新分區(qū)
Command action
e? extended
p? primary partition (1-4)
p選擇p添加主分區(qū)
Partition number(1-4): 1選擇主分區(qū)編號(hào)為1,這樣創(chuàng)建后的主分區(qū)為sdb1
First cylinder(1-2610, default 1):選擇格式化分區(qū)從第幾個(gè)柱面開始
Using defaultvalue 1直接“回車”默認(rèn)從第1個(gè)柱面開始
Last cylinder or+size or +sizeM or +sizeK (1-2610, default 2610):選擇格式化分區(qū)從第幾個(gè)柱面結(jié)束
Using defaultvalue 2610直接“回車”默認(rèn)從最后1個(gè)柱面結(jié)束
我們把所有20GB空間都格式化為一個(gè)分區(qū)了,如果有朋友想劃分多個(gè)分區(qū),如下方法
Last cylinder or+size or +sizeM or +sizeK (1-2610, default 2610):以MB為單位輸入自己想要的大小即可
這樣我們就創(chuàng)建完一個(gè)分區(qū),如果要?jiǎng)?chuàng)建更多分區(qū)可以照上面的步驟繼續(xù)創(chuàng)建。
Command (m forhelp): w鍵入w,保存設(shè)置并退出,完成新磁盤分區(qū)表創(chuàng)建
The partitiontable has been altered!
Calling ioctl() tore-read partition table.
Syncing disks.
[root@leonarding1~]# fdisk –l我們?cè)诳匆幌孪到y(tǒng)磁盤空間分配情況
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這時(shí)我們可以看到新磁盤已經(jīng)加入分區(qū)表了
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
下面我們給新磁盤的/dev/sdb1分區(qū)進(jìn)行格式化操作
[root@leonarding1~]# mkfs -t ext4 /dev/sdb1用ext4格式對(duì)/dev/sdb1分區(qū)進(jìn)行格式化
mke4fs 1.41.12(17-May-2010)
Filesystem label=
OS type: Linux操作系統(tǒng)類型Linux
Block size=4096(log=2)操作系統(tǒng)塊大小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 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 be automatically checked every 35 mounts or
180 days,whichever comes first.? Use tune4fs -c or-i to override.
到此我們的新分區(qū)格式化完畢,下面我們就要掛載上分區(qū)就可以使用啦!
[root@leonarding1~]# df –h這是我們還沒有掛載新分區(qū)之前的掛載點(diǎn)分布
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在根目錄上創(chuàng)建一個(gè)新的掛載目錄/u02
[root@leonarding1/]# mount /dev/sdb1 /u02將新磁盤分區(qū)掛載到/u02目錄下
[root@leonarding1/]# df –h這是我們掛載新分區(qū)之后的掛載點(diǎn)分布
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
現(xiàn)在我們可以正常使用新添加的磁盤空間了
[root@leonarding1/]# cd /u02
[root@leonarding1u02]# mkdir app創(chuàng)建一個(gè)app目錄試試
[root@leonarding1u02]# ll
total 20
drwxr-xr-x 2 rootroot? 4096 Apr 14 09:12 app? ? ?ok成功創(chuàng)建木有問題
drwx------ 2 rootroot 16384 Apr 14 08:59 lost+found
到此Virtualbox中Linux添加一個(gè)新磁盤->創(chuàng)建分區(qū)->格式化->掛載分區(qū)系列操作完畢
Virtualbox添加磁盤創(chuàng)建分區(qū)格式化掛載分區(qū)
開機(jī)自動(dòng)掛載新磁盤分區(qū)/dev/sdb1
[root@leonarding1 /]# vim /etc/fstab修改文件,在文件最后新增一行
/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
這樣在重啟系統(tǒng)后就會(huì)自動(dòng)掛載到/u02目錄上
總結(jié)
以上是生活随笔為你收集整理的suse linux增加新磁盘分区,Virtualbox中Linux添加新磁盘并创建分区的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python2 python3 通信_p
- 下一篇: Linux九大哲学原理,Linux/Un