linux学习命令总结⑩②

#fdisk命令:磁盘分区工具

fdisk –l:查看机器所挂硬盘个数及分区情况

[[email protected]_168_102_centos ~]# fdisk -l

Disk /dev/xvda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 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: 0x70068116

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1        1044     8385898+  83  Linux

Disk /dev/xvdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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

Disk /dev/xvdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 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

针对某一个挂载设别查看:

[[email protected]_168_102_centos ~]# fdisk -l /dev/xvda

Disk /dev/xvda: 8589 MB, 8589934592 bytes  #该设备空间80G
255 heads, 63 sectors/track, 1044 cylinders   #255个磁头;63个扇区;1044个柱面
Units = cylinders of 16065 * 512 = 8225280 bytes #每个柱面的大小约为8.225280M
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x70068116

 Device#分区序列 Boot#引导 Start#开始柱面 End#结束柱面 Blocks#容量   Id#分区类型ID    System#分区类型
/dev/xvda1        *         1            1044      8385898+        83              Linux
通过fdisk分区工具,对指定挂载设备进行操作:
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xcc40c7dc.
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或者help进入帮助界面

进入到此界面我们可以输入m或者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 #输入d删除分区
   l   list known partition types #输入l列出内核支持的分区类型ID
   m   print this menu
   n   add a new partition #输入n新建分区
   o   create a new empty DOS partition table
   p   print the partition table #输入p列出当前分区信息
   q   quit without saving changes #输入q不保存退出
   s   create a new empty Sun disklabel
   t   change a partition‘s system id #输入t调整分区类型ID
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit #输入w保存退出
   x   extra functionality (experts only)

创建一个主分区

Command (m for help): p #列出当前分区信息         

Disk /dev/xvdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0xd0807ba8

    Device Boot      Start         End      Blocks   Id  System
#当前无分区
Command (m for help): n #新建分区
Command action
   e   extended #扩展分区(无法格式化)
   p   primary partition (1-4) #主分区(最多四个)
p #选择创建主分区
Partition number (1-4): 1 #创建第一个主分区
First cylinder (1-1305, default 1): #起始柱面(始终由1开始)
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305): 200 #结束柱面(每个柱面大小约8.22M,再乘以起始柱面到结束柱面的个数就等于该分区的大小;也可以自定大小如输入+1000M/+1G)  

Command (m for help): p #列出当前分区信息 

Disk /dev/xvdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0xd0807ba8

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1               1         200     1606468+  83  Linux

创建一个扩展分区

linux学习命令总结⑩②

时间: 2024-10-11 21:36:28

linux学习命令总结⑩②的相关文章

linux学习命令总结②

#shutdown命令:系统关机.重启等 shutdown [options]- Time Time : now(马上) +#(多少分钟后) hh:mm(几点几分) 系统五分钟后关机: [[email protected]_168_102_centos ~]# shutdown 5//系统5分钟后重启 Broadcast message from [email protected]_168_102_centos (/dev/pts/0) at 16:19 ... The system is go

linux学习命令总结⑧

#chown命令:通过chown改变文件的属主和属组.在更改文件的属主或所属组时,可以使用用户名称和用户识别码设置.普通用户不能将自己的文件改变成其他的属主.其操作权限一般为管理员. 修改文件属主和属组: [[email protected]_168_102_centos ~]# ls -l total 8 drwxr-xr-x 2 wanghan hx 4096 Aug 12 10:32 abe drwxr-xr-x 2 root wanghan 4096 Aug 12 10:32 xab [

linux学习命令总结⑨

#重定向 输出重定向: 1>覆盖输出(1可省略) [[email protected]_168_102_centos tmp]# ls functions >shuchu [[email protected]_168_102_centos tmp]# cat shuchu functions [[email protected]_168_102_centos tmp]# ls fstab >shuchu [[email protected]_168_102_centos tmp]# ca

linux学习命令总结⑤

#stat命令:查看文件信息 [[email protected]_168_102_centos ~]# stat test.log File: `test.log' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: ca01h/51713d Inode: 483339 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 500/ wanghan) Access:

linux学习命令总结③

#cd ~ 回到当前用户的家目录 [[email protected]_168_102_centos etc]# pwd /etc //当前所在目录 [[email protected]_168_102_centos etc]# cd ~ //回到当前用户家木里 [[email protected]_168_102_centos ~]# pwd /root //当前用户家目录 [[email protected]_168_102_centos ~]# su wanghan [[email pro

linux学习命令总结④

#ls命令:通过ls 命令不仅可以查看linux文件夹包含的文件,而且可以查看文件权限(包括目录.文件夹.文件权限),查看目录信息等等 [[email protected]_168_102_centos /]# ls bin data etc lib lost+found mnt proc sbin srv tmp var boot dev home lib64 media opt root selinux sys usr ls –a:显示所有文件,包含.开头的隐藏文件 [[email prot

linux学习命令总结⑦

#useradd命令:建立用户帐号和创建用户的起始目录,使用权限是超级用户 [[email protected]_168_102_centos ~]# useradd test [[email protected]_168_102_centos ~]# id test uid=502(test) gid=502(test) groups=502(test) [[email protected]_168_102_centos ~]# tail -n 1 /etc/passwd test:x:502

linux学习命令总结⑥

#文件名通配 通配符: *:匹配任意长度的任意字符(0到多个) [[email protected]_168_102_centos ~]# ls * 0812080808 2014-05-16: test.log ceshi_1: test: [[email protected]_168_102_centos ~]# ls -ld t* drwxr-xr-x 2 root wanghan 4096 Aug 11 15:46 test ?:匹配任意单个字符 [[email protected]_1

Linux 学习命令之修改日期时间

Linux 学习命令之修改日期时间 一.日期时间修改 1. 查看时间和日期 [[email protected] ~]# date 2017年 11月 03日 星期五 11:39:49 CST 或 [[email protected] ~]# clock 2017年11月03日 星期五 11时42分52秒  -1.563496 seconds 显示日历 [[email protected] ~]# cal 十一月 2017 日 一 二 三 四 五 六 1  2  3  4 5  6  7  8