linux挂载磁盘及磁盘格式化
来源:互联网 发布:excel2016数据分析在哪 编辑:程序博客网 时间:2024/05/16 15:20
linux挂载磁盘及磁盘格式化
挂载好硬盘后,查看linux新磁盘的名称。
root帐号登录机器,然后使用命令fdisk -l查看。
host-1*:/home # fdisk -lDisk /dev/xvda: 42.9 GB, 42949672960 bytes255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000de3e1 Device Boot Start End Blocks Id System/dev/xvda1 2048 4208639 2103296 82 Linux swap / Solaris/dev/xvda2 * 4208640 83886079 39838720 83 LinuxDisk /dev/xvde: 1099.5 GB, 1099511627776 bytes255 heads, 63 sectors/track, 133674 cylinders, total 2147483648 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000Disk /dev/xvde doesn't contain a valid partition tableDisk /dev/sda: 42.9 GB, 42949672960 bytes255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000de3e1 Device Boot Start End Blocks Id System/dev/sda1 2048 4208639 2103296 82 Linux swap / Solaris/dev/sda2 * 4208640 83886079 39838720 83 Linux
可以看到磁盘 /dev/xvde 未挂载。
接下来使用fdisk /dev/xvde 进行分区
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
Command action 选择主分区输入P
Partition number (1-4, default 1): 分区名称输入默认的1即可
Command (m for help): nCommand action e extended p primary partition (1-4)pPartition number (1-4, default 1): 1
然后是选择其实磁盘数,输入默认值就好:
First sector (2048-2147483647, default 2048): 2048
再然后输入分区大小,可根据自己选择输入,我这里输入+800GB,标识是到存储800G的磁盘数, 因为是数据库机器分一个800G的。这个单位可以是K、M、G后面接上B就好了。注意不要掉了+号
First sector (2048-2147483647, default 2048): 2048Last sector, +sectors or +size{K,M,G} (2048-2147483647, default 2147483647): +800GBCommand (m for help):
由于还未分完,说便宜接下来继续添加一个分区,存储空间使用剩下的那部分;
Command (m for help): nCommand action e extended p primary partition (1-4)pPartition number (1-4, default 2): 2First sector (1562502048-2147483647, default 1562502048): 1562502048Last sector, +sectors or +size{K,M,G} (1562502048-2147483647, default 2147483647): 2147483647Command (m for help): nCommand action e extended p primary partition (1-4)pPartition number (1-4, default 3): 3No free sectors availableCommand (m for help):
然后在输入w写入磁盘即标识分区完成:
Command (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.
再使用fdisk -l命令可以看到这个从磁盘已经被分成了两个区。
host-1*:/home # fdisk -lDisk /dev/xvda: 42.9 GB, 42949672960 bytes255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000de3e1 Device Boot Start End Blocks Id System/dev/xvda1 2048 4208639 2103296 82 Linux swap / Solaris/dev/xvda2 * 4208640 83886079 39838720 83 LinuxDisk /dev/xvde: 1099.5 GB, 1099511627776 bytes255 heads, 63 sectors/track, 133674 cylinders, total 2147483648 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xae5c9a90 Device Boot Start End Blocks Id System/dev/xvde1 2048 1562502047 781250000 83 Linux/dev/xvde2 1562502048 2147483647 292490800 83 LinuxDisk /dev/sda: 42.9 GB, 42949672960 bytes255 heads, 63 sectors/track, 5221 cylinders, total 83886080 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000de3e1 Device Boot Start End Blocks Id System/dev/sda1 2048 4208639 2103296 82 Linux swap / Solaris/dev/sda2 * 4208640 83886079 39838720 83 Linux
接下来我们来格式化刚才的分区:(格式化可能比较慢)
mkfs -t ext3 -c /dev/xvde1 来格式化分区xvde1为ext3格式
mkfs -t ext3 -c /dev/xvde2 来格式化分区xvde1为ext3格式
格式化完成后即可挂载分区
并将挂载信息写入到自动挂载配置文件
# mkdir /opt# mount /dev/xvde1 /opt# mount /dev/xvde2 /home# vi /etc/fstab/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001-part1 swap swap defaults 0 0/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001-part2 / ext3 acl,user_xattr 1 1proc /proc proc defaults 0 0sysfs /sys sysfs noauto 0 0debugfs /sys/kernel/debug debugfs noauto 0 0usbfs /proc/bus/usb usbfs noauto 0 0devpts /dev/pts devpts mode=0620,gid=5 0 0/dev/xvde2 /home auto auto 0 0/dev/xvde1 /opt auto auto 0 0
最后两行即为添加的自动分区挂载信息,保存即可。
挂载完后使用命令df -l即可查看磁盘使用情况。
host-1*:/opt> df -lFilesystem 1K-blocks Used Available Use% Mounted on/dev/sda2 39213504 13807128 24370572 37% /udev 4020072 140 4019932 1% /devtmpfs 4020072 728 4019344 1% /dev/shm/dev/xvde2 292490800 1979336 290511464 1% /home/dev/xvde1 781250000 2006336 779243664 1% /opthost-1*:~/opt>
自此,即完成磁盘的分区级挂载操作。
- linux挂载磁盘及磁盘格式化
- linux 磁盘格式,磁盘挂载,及格式化
- linux文件系统及磁盘格式化
- linux磁盘分区磁盘格式化挂载
- Linux系统格式化磁盘+挂载分区
- Linux系统格式化磁盘+挂载分区
- Linux系统格式化磁盘+挂载分区
- Linux系统格式化磁盘+挂载分区
- Linux系统格式化磁盘+挂载分区
- Linux系统格式化磁盘+挂载分区
- Linux分区、格式化、自动挂载磁盘
- linux下格式化磁盘及分区
- linux添加及格式化新磁盘
- Linux--磁盘管理(磁盘分区、挂载卸载及磁盘限额)
- fstab 及格式化磁盘
- 磁盘格式化与挂载
- 格式化,分区,挂载磁盘
- linux 格式化磁盘
- Java编程练习目录
- 这应该是迄今为止最全的一份Java就业指导书
- 截取整个ScrollerView视图
- lua虚拟机初始化
- iOS RTMP 视频直播开发笔记(3) --- 与帧相关的概念
- linux挂载磁盘及磁盘格式化
- Python学习笔记 —— 数字类型【Numbers】及常用方法
- Android 手机抓包方法(一)
- Android DiaglogFragment 设置背景为透明
- 第十五周--阅读程序
- AJAX
- Flatten Binary Tree to Linked List
- JBAS015052: Did not receive a response to the deployment operation within the allowed timeout period
- Spring官方文档学习(0)