麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 系統 > Ubuntu > 正文

VMware下擴展ubuntu虛擬機根目錄分區

2024-06-28 16:04:28
字體:
來源:轉載
供稿:網友

原文鏈接:http://t.cn/RzCP9E2 翻譯源鏈接:http://imcczy.com/how-to-expand-the-root-filesystem-in-vmware.html

轉載說明:

此文下面的有重新需要分區的操作,分區的操作與正常裝系統分區不同,是需要手動指定扇區(sectors)的起始點的, 這里給出計算方式,其實當打出命令時也是有提示的 類似這樣的提示 Disk /dev/sda: 15 GiB, 16106127360 bytes, 31457280 sectors Units: sectors of 1 * 512 = 512 bytes sectors 就是你的硬盤當前分區總扇區大小 可以先計算出自己打算要分出的分區大小 例如 根分區 需要14G swap分1G 1024*14=14336bytes(1.4mb) *1024*1024 = 15032385536bytes(14G) 15032385536 / 512 = 29360128 sectors 得出了從起始點到此扇區結束就是14G了

年代久遠,謹慎嘗試

虛擬機用著用著空間就不夠了,google了一篇文章,試了一下,有用,征得作者同意,翻譯了下。刪了一些無關的東西。

注:

作者輸入命令時都用“sudo bash”,用sudo或者su就可以了。

再注:

涉及到磁盤分區表刪除,最好先備份整個虛擬機!

檢查文件系統:

cruz@Ubuntu:~$ sudo bash[sudo] passWord for cruz: root@ubuntu:~# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda1 9.0G 2.7G 5.9G 32% /udev 488M 4.0K 488M 1% /devtmpfs 199M 800K 198M 1% /runnone 5.0M 0 5.0M 0% /run/locknone 497M 76K 496M 1% /run/shmroot@ubuntu:~#

檢查磁盤分區表:

root@ubuntu:~# fdisk -l /dev/sdaDisk /dev/sda: 10.7 GB, 10737418240 bytes255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00001decDevice Boot Start End Blocks Id System/dev/sda1 * 2048 18874367 9436160 83 linux/dev/sda2 18876414 20969471 1046529 5 Extended/dev/sda5 18876416 20969471 1046528 82 Linux swap / Solarisroot@ubuntu:~#

記住上面顯示的交換分區大?。˙locks的數目),這里就是1046528。如果交換分區和根目錄不在一個磁盤(比如/dev/sdb),就不要記了。在本文,交換分區在/dev/sda,需要重新分區。

先關閉linux:

root@ubuntu:~# shutdown -h now

在虛擬機設置,硬盤,實用工具下選擇擴展。擴展虛擬機的最大磁盤大小,這里將磁盤設置為15G,然后重啟。

重新設置分區表要刪除所有的舊分區、關閉系統的swap:

cruz@ubuntu:~$ sudo bash[sudo] password for cruz: root@ubuntu:~# free -m total used free shared buffers cachedMem: 992 924 67 0 43 426 -/+ buffers/cache: 454 537Swap: 1021 0 1021root@ubuntu:~# swapoff -aroot@ubuntu:~# free -m total used free shared buffers cachedMem: 992 924 67 0 43 426 -/+ buffers/cache: 454 537Swap: 0 0 0root@ubuntu:~#

接下來的步驟會刪除/dev/sda1和/dev/sda2,一定要記住分區表的起始位置,這里是2048!

root@ubuntu:~# fdisk /dev/sdaCommand (m for help): pDisk /dev/sda: 16.1 GB, 16106127360 bytes255 heads, 63 sectors/track, 1958 cylinders, total 31457280 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00001dec Device Boot Start End Blocks Id System/dev/sda1 * 2048 18874367 9436160 83 Linux/dev/sda2 18876414 20969471 1046529 5 Extended/dev/sda5 18876416 20969471 1046528 82 Linux swap / SolarisCommand (m for help): dPartition number (1-5): 1Command (m for help): dPartition number (1-5): 2Command (m for help): pDisk /dev/sda: 16.1 GB, 16106127360 bytes255 heads, 63 sectors/track, 1958 cylinders, total 31457280 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00001dec Device Boot Start End Blocks Id SystemCommand (m for help):

不要退出fdisk,接著創建新分區

Command (m for help): nPartition type: p PRimary (0 primary, 0 extended, 4 free) e extendedSelect (default p): pPartition number (1-4, default 1): 1First sector (2048-31457279, default 2048): Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-31457279, default 31457279): 30410751Command (m for help): nPartition type: p primary (1 primary, 0 extended, 3 free) e extendedSelect (default p): pPartition number (1-4, default 2): Using default value 2First sector (30410752-31457279, default 30410752): Using default value 30410752Last sector, +sectors or +size{K,M,G} (30410752-31457279, default 31457279): Using default value 31457279注意記得創建交換分區,大小別搞錯,這里是1046528(31457279-30410571=1046528),即要留一部分block用于創建swap。修改sda2的分區類型為82,即交換分區。Command (m for help): pDisk /dev/sda: 16.1 GB, 16106127360 bytes255 heads, 63 sectors/track, 1958 cylinders, total 31457280 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00001dec Device Boot Start End Blocks Id System/dev/sda1 2048 30410751 15204352 83 Linux/dev/sda2 30410752 31457279 523264 83 LinuxCommand (m for help): tPartition number (1-4): 2Hex code (type L to list codes): 82Changed system type of partition 2 to 82 (Linux swap / Solaris)Command (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: Device or resource busy.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)Syncing disks.root@ubuntu:~#

重啟虛擬機:

root@ubuntu:~# shutdown -r now

交換分區掛載需要UUID標識符。創建新的交換分區不會匹配舊的UUID,導致重啟無法掛載swap分區。這里主要有兩種解決方法:在/etc/fstab里寫入新的UUID,或者直接將舊的UUID覆蓋在新分區上,這里選擇后者。 awk命令用來顯示舊的UUID,dd命令確保分區沒數據。

cruz@ubuntu:~$ sudo bash[sudo] password for cruz: root@ubuntu:~# awk '/swap/ { print $1 }' /etc/fstab#UUID=8bb62351-4436-47df-92fe-af2865f03461root@ubuntu:~# swapoff -aroot@ubuntu:~# free -m total used free shared buffers cachedMem: 992 695 296 0 23 325-/+ buffers/cache: 346 645Swap: 0 0 0root@ubuntu:~# dd if=/dev/zero of=/dev/sda2dd: writing to '/dev/sda2': No space left on device1046529+0 records in1046528+0 records out535822336 bytes (536 MB) copied, 11.9388 s, 44.9 MB/sroot@ubuntu:~# mkswap -U 8bb62351-4436-47df-92fe-af2865f03461 /dev/sda2Setting up swapspace version 1, size = 523260 KiBno label, UUID=8bb62351-4436-47df-92fe-af2865f03461root@ubuntu:~# swapon -aroot@ubuntu:~# free -m total used free shared buffers cachedMem: 992 693 298 0 23 325-/+ buffers/cache: 345 646Swap: 510 7 503root@ubuntu:~#

最后,調整分區大?。?/h4>root@ubuntu:~# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda1 9.0G 2.8G 5.8G 33% /udev 488M 4.0K 488M 1% /devtmpfs 199M 788K 198M 1% /runnone 5.0M 0 5.0M 0% /run/locknone 497M 200K 496M 1% /run/shmroot@ubuntu:~# resize2fs /dev/sda1resize2fs 1.42 (29-Nov-2011)Filesystem at /dev/sda1 is mounted on /; on-line resizing requiredold_desc_blocks = 1, new_desc_blocks = 1Performing an on-line resize of /dev/sda1 to 3801088 (4k) blocks.The filesystem on /dev/sda1 is now 3801088 blocks long.root@ubuntu:~# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda1 15G 2.8G 11G 21% /udev 488M 4.0K 488M 1% /devtmpfs 199M 788K 198M 1% /runnone 5.0M 0 5.0M 0% /run/locknone 497M 200K 496M 1% /run/shmroot@ubuntu:~#

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 三人弄娇妻高潮3p视频 | 3xxx | 免费毛片视频播放 | 一区二区三区欧美在线 | 欧美精品电影一区 | 禁漫天堂久久久久久久久久 | 日本黄色免费播放 | 久久草在线看 | 国产精品成人免费一区久久羞羞 | 在线播放免费人成毛片乱码 | 可以免费看av | 久草在线高清视频 | 国产九色在线观看 | 日韩大片在线永久观看视频网站免费 | 国产女厕一区二区三区在线视 | 青青草最新网址 | 一级成人黄色片 | 久久国产免费视频 | 久久久成人精品视频 | 中文字幕在线观看网址 | 欧美亚洲国产一区 | 久久久久久艹 | 欧美另类在线视频 | 一级在线视频 | 中国黄色一级生活片 | 人成免费网站 | 成年人视频在线免费播放 | 成人爽a毛片免费啪啪红桃视频 | 在线播放免费人成毛片乱码 | 成人免费观看49www在线观看 | 国产性tv国产精品 | 国产成人精品一区二区视频免费 | 国产999精品久久久久 | 免费一级肉体全黄毛片 | 九九热在线免费观看视频 | 91网站免费在线观看 | 毛片a级毛片免费播放100 | 久久久久久久久久久国产精品 | 国产啊v在线观看 | 久久蜜桃精品一区二区三区综合网 | 嗯~啊~用力~高h |