Linux.分区、格式化、挂载
2017-03-03 02:36
876 查看
双系统 + 小硬盘 = ubuntu空间不够用
于是用win10自带的分区工具(右键计算机-管理-磁盘管理器)删掉了一个卷,大约24G,决定将这块空间挂载到ubuntu上
如今一块500G的SSD要一千块,实在买不起
关于/dev/ram1这类设备的一篇博客
也可见到,整块硬盘大小为232.9 GiB,但是所有的分区加起来才207GiB,也就是还有25G空间,那也就是我在win10上删掉的那个卷
给这25G分个区,过程根据提示输入command就好
n:add a new partition
分好后长这样
出现了/dev/sda4,大小为25G
之后就这样了
设置为开机自动挂载
加上我这里的最后一行
每行的格式在已有的注释里已经说出来了
<源文件系统><挂载点><文件系统类型><选项>\< dump>\< pass>
dump:设置是否让备份程序dump备份文件系统,0为忽略,1为备份。
pass:告诉fsck程序以什么顺序检查文件系统,0为忽略。
我看其他的都是 0 2 ,于是我也写了0 2
搞定
关键还在于理解主分区、扩展分区、逻辑分区的概念,和他们之间的关系,才能搞清楚自己到底在干什么
于是用win10自带的分区工具(右键计算机-管理-磁盘管理器)删掉了一个卷,大约24G,决定将这块空间挂载到ubuntu上
如今一块500G的SSD要一千块,实在买不起
系统与硬盘
niugen@niugenen:~$ uname -a Linux niugenen 4.4.0-64-generic #85-Ubuntu SMP Mon Feb 20 11:50:30 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux niugen@niugenen:~$ sudo fdisk -l [sudo] niugen 的密码: Disk /dev/ram0: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram1: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram2: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram3: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram4: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram5: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram6: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram7: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram8: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram9: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram10: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram11: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram12: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram13: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram14: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/ram15: 64 MiB, 67108864 bytes, 131072 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/sda: 232.9 GiB, 250059350016 bytes, 488397168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x6d2d0206 设备 启动 Start 末尾 扇区 Size Id 类型 /dev/sda1 * 2048 169934847 169932800 81G 7 HPFS/NTFS/exFAT /dev/sda2 169934848 394025327 224090480 106.9G 7 HPFS/NTFS/exFAT /dev/sda3 394027006 435970047 41943042 20G 5 扩展 /dev/sda5 394027008 404025343 9998336 4.8G 83 Linux /dev/sda6 404027392 405002239 974848 476M 83 Linux /dev/sda7 405004288 407003135 1998848 976M 82 Linux 交换 / Solaris /dev/sda8 407005184 411002879 3997696 1.9G 83 Linux /dev/sda9 411004928 435970047 24965120 11.9G 83 Linux Disk /dev/sdb: 931.5 GiB, 1000170586112 bytes, 1953458176 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 55333591-6989-44CA-9841-239B250B344E 设备 Start 末尾 扇区 Size 类型 /dev/sdb1 2048 1953456127 1953454080 931.5G Microsoft basic data
关于/dev/ram1这类设备的一篇博客
分区
从上文可见/dev/sda3是一个扩展分区,衍生出了/dev/sda56789这五个分区,目前我整个ubuntu也就是在这五个分区上niugen@niugenen:~$ df 文件系统 1K-块 已用 可用 已用% 挂载点 udev 4010356 0 4010356 0% /dev tmpfs 805972 9644 796328 2% /run /dev/sda5 4789564 1675264 2847960 38% / /dev/sda9 12155568 8783780 2731276 77% /usr tmpfs 4029844 21112 4008732 1% /dev/shm tmpfs 5120 4 5116 1% /run/lock tmpfs 4029844 0 4029844 0% /sys/fs/cgroup /dev/sda6 463844 105084 330293 25% /boot /dev/sda8 1934672 1560648 257700 86% /home tmpfs 805972 68 805904 1% /run/user/1000
也可见到,整块硬盘大小为232.9 GiB,但是所有的分区加起来才207GiB,也就是还有25G空间,那也就是我在win10上删掉的那个卷
给这25G分个区,过程根据提示输入command就好
n:add a new partition
分好后长这样
niugen@niugenen:~$ sudo fdisk /dev/sda [sudo] niugen 的密码: Welcome to fdisk (util-linux 2.27.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. 命令(输入 m 获取帮助): p Disk /dev/sda: 232.9 GiB, 250059350016 bytes, 488397168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x6d2d0206 设备 启动 Start 末尾 扇区 Size Id 类型 /dev/sda1 * 2048 169934847 169932800 81G 7 HPFS/NTFS/exFAT /dev/sda2 169934848 394025327 224090480 106.9G 7 HPFS/NTFS/exFAT /dev/sda3 394027006 435970047 41943042 20G 5 扩展 /dev/sda4 435970048 488397167 52427120 25G 83 Linux /dev/sda5 394027008 404025343 9998336 4.8G 83 Linux /dev/sda6 404027392 405002239 974848 476M 83 Linux /dev/sda7 405004288 407003135 1998848 976M 82 Linux 交换 / Solaris /dev/sda8 407005184 411002879 3997696 1.9G 83 Linux /dev/sda9 411004928 435970047 24965120 11.9G 83 Linux Partition table entries are not in disk order. 命令(输入 m 获取帮助): q
出现了/dev/sda4,大小为25G
格式化
$ mkfs -t ext4 /dev/sda4
挂载
$ mount /dev/sda4 /home/niugen/disk
之后就这样了
niugen@niugenen:~$ df -lhT 文件系统 类型 容量 已用 可用 已用% 挂载点 udev devtmpfs 3.9G 0 3.9G 0% /dev tmpfs tmpfs 788M 9.5M 778M 2% /run /dev/sda5 ext4 4.6G 1.6G 2.8G 38% / /dev/sda9 ext4 12G 8.4G 2.7G 77% /usr tmpfs tmpfs 3.9G 14M 3.9G 1% /dev/shm tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda6 ext4 453M 103M 323M 25% /boot /dev/sda8 ext4 1.9G 1.5G 251M 86% /home /dev/sda4 ext4 25G 44M 24G 1% /home/niugen/disk tmpfs tmpfs 788M 88K 787M 1% /run/user/1000 /dev/sdb1 fuseblk 932G 758G 175G 82% /media/niugen/Elements /dev/sda2 fuseblk 107G 57G 51G 54% /media/niugen/0006FC6000004495
设置为开机自动挂载
$ sudo gedit /etc/fstab
加上我这里的最后一行
niugen@niugenen:~$ cat /etc/fstab # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/sda5 during installation UUID=b5816071-6ad8-4676-bfd6-a3a780e2b574 / ext4 errors=remount-ro 0 1 # /boot was on /dev/sda6 during installation UUID=5fd70596-6fc0-4f4c-8b0e-3fe9eae8b605 /boot ext4 defaults 0 2 # /home was on /dev/sda8 during installation UUID=607b284d-802a-4a0e-bcab-efb2f1065fa6 /home ext4 defaults 0 2 # /usr was on /dev/sda9 during installation UUID=d7f6f351-05f5-454e-b63e-88cbdf0e440d /usr ext4 defaults 0 2 # swap was on /dev/sda7 during installation UUID=3354a04d-6019-43eb-be82-20de08126d9d none swap sw 0 0 /dev/sda4 /home/niugen/disk ext4 defaults 0 2
每行的格式在已有的注释里已经说出来了
# <file system> <mount point> <type> <options> <dump> <pass>
<源文件系统><挂载点><文件系统类型><选项>\< dump>\< pass>
dump:设置是否让备份程序dump备份文件系统,0为忽略,1为备份。
pass:告诉fsck程序以什么顺序检查文件系统,0为忽略。
我看其他的都是 0 2 ,于是我也写了0 2
搞定
关键还在于理解主分区、扩展分区、逻辑分区的概念,和他们之间的关系,才能搞清楚自己到底在干什么
相关文章推荐
- linux fdisk 分区、格式化、挂载
- linux磁盘空间不足 和 挂载新硬盘(含磁盘格式化、分区)方法
- linux fdisk 分区、格式化、挂载!fdisk 分区 格式化 自动挂载! ext3格式化, ext4格式化 及挂载
- Linux运维实战之磁盘分区、格式化及挂载(一) 推荐
- (转载)linux下分区、格式化、挂载的命令
- Linux添加新硬盘、分区、格式化、自动挂载
- linux硬盘的分区、格式化、挂载以及LVM
- linux 硬盘分区,分区,删除分区,格式化,挂载,卸载笔记
- Virtualbox中Linux添加一个新磁盘->创建分区->格式化->挂载分区
- [Linux] 磁盘的分区、格式化、检验与挂载
- linux下分区、格式化、挂载新硬盘的详细过程
- Linux系统如何分区、格式化、挂载
- Linux添加新硬盘、分区、格式化、自动挂载
- linux 硬盘分区,分区,删除分区,格式化,挂载,卸载笔记
- linux 多硬盘 分区格式化自动挂载知识点
- 怎样将一个windows硬盘重新分区,格式化,并挂载到linux系统内
- linux fdisk 分区、格式化、挂载!
- LINUX中的分区,格式化,挂载安全(上) 推荐
- Linux添加新硬盘、分区、格式化、自动挂载
- Linux添加新硬盘、分区、格式化、自动挂载