linux磁盘相关操作
2015-06-03 20:30
316 查看
查看哪些磁盘挂载着: sudo fdisk -l
分区和格式化: sudo fdisk /dev/sdd
格式化:
查看已有分区格式: df -T -h。
根据现有分区格式格式新的分区: mkfs.ext4 /dev/sdd1
挂载到文件夹:
mkdir ~/work
mount /dev/sdd1 ~/work
按以上方法挂载的文件夹在重启后需要重新挂载,若要重启后也有效,需使用修改/etc/fstab文件的方法,在该文件最后添加如下内容:
Disk /dev/sdd: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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 Disk identifier: 0x00000000
分区和格式化: sudo fdisk /dev/sdd
ckt@ubuntu:~$ sudo fdisk /dev/sdd Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xfee324c4. 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) 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 #添加一个新分区 Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p #主分区 Partition number (1-4, default 1): 1 #1个分区 First sector (2048-41943039, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): Using default value 41943039 Command (m for help): p #打印分区表 Disk /dev/sdd: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders, total 41943040 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 Disk identifier: 0xfee324c4 Device Boot Start End Blocks Id System /dev/sdd1 2048 41943039 20970496 83 Linux Command (m for help): w #保存修改 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
格式化:
查看已有分区格式: df -T -h。
根据现有分区格式格式新的分区: mkfs.ext4 /dev/sdd1
挂载到文件夹:
mkdir ~/work
mount /dev/sdd1 ~/work
按以上方法挂载的文件夹在重启后需要重新挂载,若要重启后也有效,需使用修改/etc/fstab文件的方法,在该文件最后添加如下内容:
/dev/sdd1 /home/ckt/work ext4 defaults 0 1
相关文章推荐
- Linux进程间通信——使用消息队列
- linux下sh脚本定时删除文件
- CentOS-6.4-minimal版中安装JDK_Maven_Subversion以及修改rpm包安装路径
- Linux进程间通信——使用共享内存
- CentOS系统中与时间相关的几个命令
- ubuntu 15.04 & vmware 11 针对vmnet问题的patch
- Linux启动新进程的几种方法及比较
- Linux进程间通信——使用信号
- linux定时任务
- Linux进程间通信——信号集函数
- Linux进程间通信——使用匿名管道
- Linux进程间通信——使用命名管道
- linux sar命令详解
- mediawiki搭建总结-centos
- linux tar压缩和解压
- Linux 使用光盘yum源的方法
- Linux 驱动之内核定时器
- Linux中如何创建静态库和动态库
- Linux进程概念&相关系统调用(6.3)
- Linux 查找指定名称的进程并显示进程详细信息