#4. Device Management for Linux

Source: Internet
Author: User

Device files are stored in the/dev directory This file provides some information about the device, file type B, C, p, s start file or directory is a device file, roughly for a few /DEV/SDA is the first interface type device for SATA. /DEV/HDB Second IDE type interface Device block device: If SDA1 is a block device, its capacity size fixed character device: such as the printer, it does not have a fixed capacity size, when the character device read and write, the kernel will be read and write to the corresponding device equipment: a pipe, there are in and out, A local socket device that directs data to need: The pair interface used when communicating across processesFile System TypeJust like the file system format under Windows FAT16, FAT32, Ntfs,linux have ext2 3 4 xfs file types to choose from Ext4 and XFS are newer file types, different types of file systems differ in read/write speed, random read/write speed, lookup operation,How many fragments are produced,The amount of time and speed required to extract the fragments from the Operation

Disk partitioning

Case

/DEV/SDA1 boot partition

/DEV/SDA2 Swap partition

/DEV/SDA3 Root Partition

  1. #以SATA接口的硬盘为例
  2. fdisk -l #查看所有硬盘和分区信息
  3. fdisk /dev/sda
  4. #进入fdisk模式
  5. 输入 n 建立引导分区
  6. 输入 p 确认创建主分区
  7. 输入1此为分区号
  8. 输入起始位置回车
  9. 输入结束位置+300M
  10. 输入 a
  11. 输入1
  12. #这样一个300M启动分区建立完成,并设置为启动状态,键入print可查看到 boot处有*标志
  13. #建立swap分区
  14. 输入 n 建立交换分区
  15. 输入 p 确认创建主分区
  16. 输入2分区号
  17. 输入起始位置回车
  18. 输入结束位置+1024M
  19. 输入 t 设置分区类型
  20. 输入82此为交换分区类型
  21. 输入 print 查看当前分区信息
  22. #建立根分区
  23. 输入 n
  24. 输入 p 确认创建主分区
  25. 输入3分区号
  26. 输入起始位置回车
  27. 输入结束位置回车使用剩余全部空间
  28. #完成键入 print查看分区信息
  29. 输入 w 对分区操作进行保存
  30. Calling ioctl() to re-read partition table.Syncing disks.
Next you need to format the partition

    1. mkfs.ext3 /dev/sda1
    2. mkfs.ext4 /dev/sda3
    3. mkswap /dev/sda2
Collection of commands available in Fdisk mode
  1. Command(m for help): m
  2. Command action
  3. a toggle a bootable flag
  4. b edit bsd disklabel
  5. c toggle the dos compatibility flag
  6. d delete a partition
  7. l list known partition types
  8. m print this menu
  9. n add a new partition
  10. o create a new empty DOS partition table
  11. p print the partition table
  12. q quit without saving changes
  13. s create a new empty Sun disklabel
  14. t change a partition‘s system id
  15. u change display/entry units
  16. v verify the partition table
  17. w write table to disk and exit
  18. x extra functionality (experts only)
Disk Mount
  1. #mount 将要挂载的文件的格式 文件位置 挂载点
  2. mount -t iso9660 /dev/dvd /mnt # 挂载光驱
  3. mount -t ntfs-3g/dev/sdc1 /media/cdrom # 挂载ntfs硬盘
  4. mount -t vfat /dev/sda1 /mnt/usb # 挂载USB
  5. mount -o loop /xxx/**.iso /mnt/ # 挂载xxx目录下的镜像文件到mnt目录
  6. mount -t nfs 192.168.1.1:/home/aaa /home/bbb/mt
  7. #将NFS服务器上home目录下的aaa文件夹 挂载到本机home目录下bbb目录的mt目录下
Device monitoring
    1. udevadm monitor
Can monitor the usage record of USB stick,Udevadm is a common management tool for other uses, you can use the manUdevadm ViewView disk Information
    1. df #显示磁盘使用信息
    2. du #显示目录或文件占用磁盘信息
    3. quota #显示磁盘已使用和空间限额信息
LVMLVM is a shorthand for Logical Volume Manager (Logical Volume management), which is a mechanism for managing disk partitions in a Linux environment. When partitioning a system, how to accurately evaluateallocate the capacity of each hard disk partition, as the system administrator takes into account not only the capacity required by the current partition, but also the maximum amount of capacity that may be required after the partition. Because if the estimate is inaccurate, the administrator may even want to back up the entire system, clear the hard disk, re-partition the hard disk, and then restore the data to the new partition when a partition is not sufficient. LVM is a logical layer built on hard disks and partitions to improve the flexibility of disk partition management. The LVM system administrator makes it easy to manage disk partitions, such as connecting several disk partitions to a single block of volume group (volumegroup), forming a storage pool. Administrators can create logical volume groups (logicalvolumes) at will on a volume group and further create file systems on logical volume groups. LVM makes it easy for administrators to resize storage volume groups and to name, manage, and assign disk storage as a group. (The content of this paragraph from Baidu Encyclopedia)
GRUB Boot Process(1) the BIOS or boot firmware loads and runs the boot loader. (2) The boot loader locates the kernel image on the disk, loads it into memory, and starts it. (3) The kernel initializes the device and device driver. (4) The kernel mounts the root file system. (5) The kernel uses the process number as a PID to run a program called INIT, User space starts at this time. (6) Init initiates other system processes. (7) Init also initiates a process that typically occurs at the end of the process and is responsible for user logons. Start the run Level 3-bit command-line mode, and 5 for the graphical interface mode. You can modify the boot level in the/etc/inittab file to require root permissions



From for notes (Wiz)



#4. Device Management for Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.