很少說,直接上乾貨!php
本博文的主要內容有html
.磁盤分區的概述node
.經常使用的磁盤管理工具linux
./下分5G,給/home擴容數據庫
.系統自帶的fdisk和parted這兩款工具ubuntu
.磁盤空間管理微信
前言app
系統自帶的fdisk和parted這兩款工具,能夠爲咱們提供更方便地對磁盤空間進行查看和管理的能力,也可使用帶-l選項的fdisk命令來查看某塊磁盤上更新詳細的信息。機器學習
磁盤分區的概述ide
磁盤由兩個分區組成,即分爲主分區和擴展分區,擴展分區又可由多個邏輯分區組成。
咱們在安裝linux系統時,若使用自動分區的方式進行磁盤分區,系統則將自動將分紅兩個分區,即根分區/和交換分區swap。交換分區的做用是充當虛擬內存,主要是物理內存不足時用於暫時對數據進行保存,並在須要時進行調用。因爲交換分區只能用於暫時數據的存儲,所以系統還必須有一股分區用於長期存儲文件及數據。
Linux系統下的磁盤類型有IDE和SCSI這兩種。固然,這些磁盤設備也被映射到一個系統文件上。對於這兩種磁盤的命名方式,IDE的命名方式採用/dec/hdx(x表明磁盤快),而其下的分區則是/dec/hdxy(y表明該磁盤塊上的分區號).SCSI則採用/dev/sdx,其下的分區是/dev/sdxy。
對於Linux的磁盤分區,至少要有/分區、boot分區和swap分區。不然,安裝會受阻,考慮到實際的工做環境及後期對磁盤的維護(如後期磁盤空間須要擴容,在Linux系統下安裝Oracle數據庫)等。Linux磁盤分區的格式建議是LVM格式,而設計Oracle的安裝時,swap分區每每與物理內存對應,所以在實際的工做環境下安裝系統時應該作好分區工做。
推薦
下載地址:http://pan.baidu.com/s/1c2iLrji
磁盤管理工具是系統管理員須要常用的軟件,是完成磁盤管理的重要手段。經常使用的磁盤管理工具包括:fdisk、Partition Magic、parted、mkfs和e2fsck。
使用partprobe重載分區也只能是對不一樣的硬盤才能及時生效。對於同一塊硬盤,修改過度區信息後,必須重啓系統才能使修改過的分區信息生效。(好比,SCSI硬盤和IDE硬盤。)
問題的描述
能夠看出,個人虛擬機裏的這個系統,因以前,在安裝分區時,未考慮周到,/home的容量過小了,如今,我想,但願從/下分5G容量給/home?
或者,新建一磁盤,來進行對分區的擴容。(實則,是想從/dev/sdb擴容5G到/dev/sda下的/home)。求解!!!
流程:添加磁盤 -> 使用fdisk建立磁盤分區 -> 使用parted工具建立分區 -> 掛載磁盤分區到系統
一、使用fdisk -l查詢當前系統分區狀況
[root@weekend110 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda5 16G 3.7G 12G 25% / tmpfs 931M 232K 931M 1% /dev/shm /dev/sda1 194M 30M 155M 16% /boot /dev/sda2 2.9G 2.8G 0 100% /home /dev/sr0 4.2G 4.2G 0 100% /media/CentOS_6.5_Final [root@weekend110 ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000491de Device Boot Start End Blocks Id System /dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 26 409 3072000 83 Linux Partition 2 does not end on cylinder boundary. /dev/sda3 409 536 1024000 82 Linux swap / Solaris Partition 3 does not end on cylinder boundary. /dev/sda4 536 2611 16669696 5 Extended /dev/sda5 536 2611 16668672 83 Linux [root@weekend110 ~]#
能夠看到新增長的sda磁盤尚未分區!!!
重啓機器,後,再次執行
[root@weekend110 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda5 16G 3.7G 12G 25% / tmpfs 931M 72K 931M 1% /dev/shm /dev/sda1 194M 30M 155M 16% /boot /dev/sda2 2.9G 2.8G 0 100% /home [root@weekend110 ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000491de 想說的是,一看/dev/sda,就是原來的硬盤。 Device Boot Start End Blocks Id System /dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 26 409 3072000 83 Linux Partition 2 does not end on cylinder boundary. /dev/sda3 409 536 1024000 82 Linux swap / Solaris Partition 3 does not end on cylinder boundary. /dev/sda4 536 2611 16669696 5 Extended /dev/sda5 536 2611 16668672 83 Linux Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 想說的是,一看/dev/sda,就是新增的硬盤。
[root@weekend110 ~]# ll /dev/sd* brw-rw----. 1 root disk 8, 0 Oct 18 20:04 /dev/sda brw-rw----. 1 root disk 8, 1 Oct 18 20:04 /dev/sda1 brw-rw----. 1 root disk 8, 2 Oct 18 20:04 /dev/sda2 brw-rw----. 1 root disk 8, 3 Oct 18 20:04 /dev/sda3 brw-rw----. 1 root disk 8, 4 Oct 18 20:04 /dev/sda4 brw-rw----. 1 root disk 8, 5 Oct 18 20:04 /dev/sda5 brw-rw----. 1 root disk 8, 16 Oct 18 20:04 /dev/sdb [root@weekend110 ~]# fdisk -l /dev/sdb Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 [root@weekend110 ~]#
可見,該新增的磁盤/dec/sdb,上沒有建立任何分區。
[root@weekend110 ~]# clear [root@weekend110 ~]# fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xace34bc7. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): m Command action a toggle a bootable flag //設置可引導的標記 b edit bsd disklabel //修改bsd磁盤的標籤 c toggle the dos compatibility flag //設置dos的兼容性 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 //建立一個新的、空的DOS分區表 p print the partition table //顯示當前的分區表 q quit without saving changes //退出操做、不保存修改 s create a new empty Sun disklabel //建立一個新的、空的Sun磁盤標籤 t change a partition's system id //更改系統分區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):
2.建立主分區
由於,新增磁盤,是sdb。
fdisk /dev/sdb
輸入n
[root@weekend110 ~]# fdisk /dev/sdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xf5778f69. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): n Command action e extended p primary partition (1-4)
提示說,輸入p
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): 1 Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +10G Command (m for help):
在輸入結束柱面的這裏若是你不知道該輸入多大的數字,你能夠輸入+而後輸入你要設的大小。這裏我設置10G的主分區。
輸入p查看分區信息,能夠看到剛建立的sdb1主分區。
Command (m for help): p //查看當前分區表 Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xc0585a2e Device Boot Start End Blocks Id System /dev/sdb1 1 1306 10490413+ 83 Linux Command (m for help): Command (m for help): w //保存退出 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@weekend110 ~]#
三、建立擴展分區
Command (m for help): n Command action e extended p primary partition (1-4) e Partition number (1-4): 2 First cylinder (1307-2610, default 1307): 1307 Last cylinder, +cylinders or +size{K,M,G} (1307-2610, default 2610): 2610 Command (m for help): p //查看當前的分區表 Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xc0585a2e Device Boot Start End Blocks Id System /dev/sdb1 1 1306 10490413+ 83 Linux /dev/sdb2 1307 2610 10474380 5 Extended Command (m for help):
圖片上經過紅色標註了操做步驟。能夠看到當前已建立了sdb2擴展分區,柱面從1037-2610,即將剩下的全部空間建立爲擴展分區。
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@weekend110 ~]#
4.建立邏輯分區
Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (1307-2610, default 1307): 1307 Last cylinder, +cylinders or +size{K,M,G} (1307-2610, default 2610): +2G Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (1569-2610, default 1569): 1560^H Value out of range. First cylinder (1569-2610, default 1569): 1569 Last cylinder, +cylinders or +size{K,M,G} (1569-2610, default 2610): 2610 Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xc0585a2e Device Boot Start End Blocks Id System /dev/sdb1 1 1306 10490413+ 83 Linux /dev/sdb2 1307 2610 10474380 5 Extended /dev/sdb5 1307 1568 2104483+ 83 Linux /dev/sdb6 1569 2610 8369833+ 83 Linux Command (m for help):
總共建立了兩個邏輯分區,邏輯分區默認從5開始,第一個邏輯分區大小2G,用來作交換分區用,剩下所有給sdb6.
Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xace34bc7 Device Boot Start End Blocks Id System /dev/sdb1 1 1306 10490413+ 83 Linux /dev/sdb2 1307 2610 10474380 5 Extended /dev/sdb5 1307 1568 2104483+ 83 Linux /dev/sdb6 1569 2610 8369833+ 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@weekend110 ~]#
五、修改文件類型ID
由於默認分區id都是83即linux文件類型,如今將sdb5的文件類型ID改爲82即交換分區。
Command (m for help): t Partition number (1-6): 5 Hex code (type L to list codes): 82 Changed system type of partition 5 to 82 (Linux swap / Solaris) Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xc0585a2e Device Boot Start End Blocks Id System /dev/sdb1 1 1306 10490413+ 83 Linux /dev/sdb2 1307 2610 10474380 5 Extended /dev/sdb5 1307 1568 2104483+ 82 Linux swap / Solaris /dev/sdb6 1569 2610 8369833+ 83 Linux Command (m for help):
六、保存退出
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): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [root@weekend110 ~]#
7.格式化分區
接下來要對sdb的每個分區進行格式化,
注意:擴展分區不須要進行格式
[root@weekend110 ~]# mkfs.ext4 /dev/sdb1 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 655776 inodes, 2622603 blocks 131130 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2688548864 81 block groups 32768 blocks per group, 32768 fragments per group 8096 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 25 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@weekend110 ~]# [root@weekend110 ~]# mkfs.ext4 /dev/sdb1 或者 [root@weekend110 ~]# mkfs -t ext4 /dev/sdb1 是等價的。
[root@weekend110 ~]# mkfs -t ext4 /dev/sdb1 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 655776 inodes, 2622603 blocks 131130 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2688548864 81 block groups 32768 blocks per group, 32768 fragments per group 8096 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 23 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@weekend110 ~]#
[root@weekend110 ~]# mkfs.ext4 /dev/sdb6 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 523264 inodes, 2092458 blocks 104622 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2143289344 64 block groups 32768 blocks per group, 32768 fragments per group 8176 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 25 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@weekend110 ~]#
swap分區格式化要使用
mkswap /dev/sdb5 mkswap,是mkdir swap。
[root@weekend110 ~]# mkswap /dev/sdb5 Setting up swapspace version 1, size = 2104476 KiB no label, UUID=d28dfa28-7303-463a-ae0c-b1751786c656 [root@weekend110 ~]#
加載文件
swapon /dev/sdb5
查看是否生效
swapon -s
[root@weekend110 ~]# swapon /dev/sdb5 [root@weekend110 ~]# swapon -s Filename Type Size Used Priority /dev/sda3 partition 1023992 0 -1 /dev/sdb5 partition 2104472 0 -2 [root@weekend110 ~]#
能夠看到sda3,和sdb5這兩個swap分區。
8.掛載分區
這裏直接使用修改文件的方式永久掛載
建立掛載文件路徑
mkdir sdb1 sdb6
[root@weekend110 ~]# mkdir sdb1 sdb6 [root@weekend110 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda5 16G 3.7G 12G 25% / tmpfs 931M 72K 931M 1% /dev/shm /dev/sda1 194M 30M 155M 16% /boot /dev/sda2 2.9G 2.8G 0 100% /home [root@weekend110 ~]#
# # /etc/fstab # Created by anaconda on Mon Jul 18 18:45:01 2016 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=f664c4a8-f9ea-4999-b914-4071e8efdff2 / ext4 defaults 1 UUID=2da787fb-94f8-4f6a-8d75-15d66628c818 /boot ext4 defaults 1 2 UUID=77fd7f45-c1e6-4014-a21e-75fe308e7edd /home ext4 defaults 1 2 UUID=98519c68-56ea-450e-b2e7-ca329d379e05 swap swap defaults 0 0 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/sdb1 /sdb1 ext4 defaults 0 0 /dev/sdb5 swap swap defaults 0 0 /dev/sdb6 /sdb6 ext4 defaults 0 0
9.當即生效
partprobe
[root@weekend110 ~]# partprobe Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only. Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only. Error: Invalid partition table - recursive partition on /dev/sr0. [root@weekend110 ~]#
在個人虛擬機上面沒法當即生效,重啓機器。
shutdown -r now
[root@weekend110 ~]# shutdown -r now Broadcast message from root@weekend110 (/dev/pts/0) at 23:58 ... The system is going down for reboot NOW! [root@weekend110 ~]#
沒生效,那是由於,遇到了
Error: Invalid partition table - recursive partition on /dev/sr0.
參考博客:
http://www.mincoder.com/article/3454.shtml
決方法:執行partprobe 命令
partprobe包含在parted的rpm軟件包中。
partprobe能夠修改kernel中分區表,使kernel從新讀取分區表。
所以,使用該命令就能夠建立分區而且在不從新啓動機器的狀況下系統可以識別這些分區。
[root@weekend110 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda5 16G 3.7G 12G 25% / tmpfs 931M 72K 931M 1% /dev/shm /dev/sda1 194M 30M 155M 16% /boot /dev/sda2 2.9G 2.8G 0 100% /home
[root@weekend110 ~]# partprobe Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only. Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only. Error: Invalid partition table - recursive partition on /dev/sr0. [root@weekend110 ~]# rpm -q parted parted-2.1-21.el6.x86_64 [root@weekend110 ~]# partprobe Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only. Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only. Error: Invalid partition table - recursive partition on /dev/sr0. [root@weekend110 ~]# mkfs -t ext4 /dev/sr0 mke2fs 1.41.12 (17-May-2010) /dev/sr0 is entire device, not just one partition! Proceed anyway? (y,n) y /dev/sr0: Read-only file system while setting up superblock [root@weekend110 ~]# partprobe Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only. Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only. Error: Invalid partition table - recursive partition on /dev/sr0. [root@weekend110 ~]#
出現這個問題,我查閱了一些資料,如http://www.linuxdiyf.com/viewarticle.php?id=312338
主要是由於是使用的虛擬機,若是是直接在Linux系統上,不會出現這個問題。
如:http://bbs.51cto.com/thread-1118884-1.html
在虛擬機中把光驅移除後,從新進入虛擬機新建分區,並經過partprobe重載分區,就沒有/dev/sr0 出現遞歸分區的錯誤信息了。
[root@weekend110 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda5 16G 3.7G 12G 25% / tmpfs 931M 72K 931M 1% /dev/shm /dev/sda1 194M 30M 155M 16% /boot /dev/sda2 2.9G 2.3G 524M 82% /home [root@weekend110 ~]# partprobe Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot.
可是仍然提示重載分區不成功,提示設備或資源忙,須要重啓生效。
直接格式化新建的分區,提示找不到新建的/dev/sdb分區。
重啓系統後,在格式化新建的分區/dev/sdb,成功。
[root@weekend110 ~]# partprobe Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. [root@weekend110 ~]# mkfs -t ext4 /dev/sdb //分區格式化 mke2fs 1.41.12 (17-May-2010) /dev/sdb is entire device, not just one partition! Proceed anyway? (y,n) y /dev/sdb is apparently in use by the system; will not make a filesystem here!
再次嘗試,
[root@weekend110 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda5 16G 3.7G 12G 25% / tmpfs 931M 72K 931M 1% /dev/shm /dev/sda1 194M 30M 155M 16% /boot /dev/sda2 2.9G 2.3G 524M 82% /home [root@weekend110 ~]# partprobe Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. [root@weekend110 ~]# mkfs -t ext4 /dev/sdb1 //格式化主分區 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 655776 inodes, 2622603 blocks 131130 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2688548864 81 block groups 32768 blocks per group, 32768 fragments per group 8096 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. [root@weekend110 ~]# mkfs -t ext4 /dev/sdb5 mke2fs 1.41.12 (17-May-2010) /dev/sdb5 is mounted; will not make a filesystem here! [root@weekend110 ~]# mkfs -t ext4 /dev/sdb6 mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 523264 inodes, 2092458 blocks 104622 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2143289344 64 block groups 32768 blocks per group, 32768 fragments per group 8176 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 36 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@weekend110 ~]# partprobe Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. Warning: WARNING: the kernel failed to re-read the partition table on /dev/sdb (Device or resource busy). As a result, it may not reflect all of your changes until after reboot. [root@weekend110 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda5 16G 3.7G 12G 25% / tmpfs 931M 72K 931M 1% /dev/shm /dev/sda1 194M 30M 155M 16% /boot /dev/sda2 2.9G 2.3G 524M 82% /home [root@weekend110 ~]#
依然,仍是解決不了。
[root@weekend110 ~]# mount /dev/sdb1 /home //掛載分區/dev/sdb1到掛載點/home [root@weekend110 ~]# mount /dev/sda5 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0") /dev/sda1 on /boot type ext4 (rw) /dev/sda2 on /home type ext4 (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) /dev/sdb1 on /home type ext4 (rw) [root@weekend110 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda5 16G 3.7G 12G 25% / tmpfs 931M 72K 931M 1% /dev/shm /dev/sda1 194M 30M 155M 16% /boot /dev/sda2 9.9G 151M 9.3G 2% /home /dev/sdb1 9.9G 151M 9.3G 2% /home [root@weekend110 ~]#
至於,刪除磁盤分區,爲何呢?
答:在實際工做中,咱們須要建立的分區來存放不一樣的數據和文件。當這些數據再也不須要時,這個專門存儲這些數據和文件的分區幾乎沒有存在的意義。而對於這些沒有存在乎義的分區,則須要將其刪除,方便管理分區。
刪除磁盤分區,很簡單,這裏很少贅述。
後面我在本身實驗室裏,嘗試成功。以下
磁盤空間管理
不管是操做系統的磁盤空間有多大,在使用過程當中可用空間總會不斷減少,雖然在磁盤空間已滿的狀況下可把數據另存到其餘的磁盤,但在實際的生產環境下,數據是連續的,所以對於某個位置下的數據,是不能將其中的某些部分移到其餘的磁盤中存放的。
要保證數據的連續性,而磁盤的可用空間又不斷減小,雖然可用加磁盤,但並不能保證數據的連續性。並且對於海量的數據,僅靠單個磁盤的空間是不能存儲的,即便使用多塊磁盤拼接在一塊兒造成RIAD即廉價磁盤冗餘陣列,固定的磁盤空間也並不能無限地存儲不斷增加的數據。
對於這個問題,在Linux系統中可使用邏輯卷的方式來解決。Linux系統支持對邏輯卷空間不斷地擴展,而且實如今線的方式擴展。
一、磁盤分區擴容
二、擴展交換分區空間
參考博客:
http://www.3fwork.com/b902/002559MYM000559/
http://www.linuxdiyf.com/viewarticle.php?id=312338
http://www.mincoder.com/article/3454.shtml
http://bbs.51cto.com/thread-1118884-1.html
同時,你們能夠關注個人我的博客:
http://www.cnblogs.com/zlslch/ 和 http://www.cnblogs.com/lchzls/ http://www.cnblogs.com/sunnyDream/
詳情請見:http://www.cnblogs.com/zlslch/p/7473861.html
人生苦短,我願分享。本公衆號將秉持活到老學到老學習無休止的交流分享開源精神,匯聚於互聯網和我的學習工做的精華乾貨知識,一切來於互聯網,反饋回互聯網。
目前研究領域:大數據、機器學習、深度學習、人工智能、數據挖掘、數據分析。 語言涉及:Java、Scala、Python、Shell、Linux等 。同時還涉及日常所使用的手機、電腦和互聯網上的使用技巧、問題和實用軟件。 只要你一直關注和呆在羣裏,天天必須有收穫
對應本平臺的討論和答疑QQ羣:大數據和人工智能躺過的坑(總羣)(161156071)