{"id":1231,"date":"2020-06-13T22:11:21","date_gmt":"2020-06-13T14:11:21","guid":{"rendered":"https:\/\/www.wjxy.net.cn\/?p=1231"},"modified":"2023-10-04T06:32:43","modified_gmt":"2023-10-03T22:32:43","slug":"linux%e9%80%9a%e8%bf%87sda%e8%8e%b7%e5%8f%96%e7%a1%ac%e7%9b%98id-uuid%e5%af%b9%e5%ba%94%e5%8f%8a%e4%bf%ae%e6%94%b9","status":"publish","type":"post","link":"https:\/\/www.wjxy.net.cn\/?p=1231","title":{"rendered":"Linux\u901a\u8fc7SDA\u83b7\u53d6\u786c\u76d8ID\/UUID\u5bf9\u5e94\u53ca\u4fee\u6539"},"content":{"rendered":"\n<p>\/dev\/disk\/by-id<\/p>\n\n\n\n<p><code> udevadm info -q symlink\u00a0-n \/dev\/sdb <\/code><br><code> udevadm info \/dev\/sdb <\/code><\/p>\n\n\n\n<p>UUID<\/p>\n\n\n\n<p> blkid <br> lsblk\u00a0-o name,mountpoint,size,uuid <br> \u00a0ls\u00a0-lh\u00a0\/dev\/disk\/by-uuid\/ <br> hwinfo\u00a0&#8211;block\u00a0|\u00a0grep\u00a0by-uuid\u00a0|\u00a0awk\u00a0&#8216;{print $3,$7}&#8217; <br> udevadm\u00a0info\u00a0-q all\u00a0-n\u00a0\/dev\/sdc1\u00a0|\u00a0grep\u00a0-i by-uuid\u00a0|\u00a0head\u00a0-1 <br> \u00a0tune2fs\u00a0-l\u00a0\/dev\/sdc1\u00a0|\u00a0grep\u00a0UUID <\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u4fee\u6539linux\u78c1\u76d8\u7684uuid<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5220\u9664\u6570\u636e\u76d8\u5e76\u518d\u5ea6\u5206\u533a\u548c\u683c\u5f0f\u5316\u540e\uff0c\u91cd\u542f\u4f1a\u62a5\u9519\uff0c\u6b64\u65f6\u5982\u4f55\u89e3\u51b3\u95ee\u9898\uff1f\n\n1\uff09\u5f97\u5230uuid \n \n# blkid \/dev\/sdb1\n\/dev\/sdb1: UUID=\"294c8a0c-86e1-441f-8e5a-df5a4fc4585a\" TYPE=\"ext4\" \n \n\u6216\n# ls -l \/dev\/disk\/by-uuid\/ |grep sdb\nlrwxrwxrwx 1 root root 10 Jul 29 10:26 294c8a0c-86e1-441f-8e5a-df5a4fc4585a -> ..\/..\/sdb1\n\n\n2\uff09\u66f4\u65b0\u539f\u6765\u7684uuid\n# mount \u2013o remount,rw \/\n# vim \/etc\/fstab\n\n\u5c06\uff1a\nUUID=8fc1e2f4-a6b4-4c5c-99d9-c6ae545a6d63 \/data                   ext4    defaults        1 2\n\u4fee\u6539\u4e3a\uff1a\nUUID=294c8a0c-86e1-441f-8e5a-df5a4fc4585a \/data                   ext4    defaults        1 2\n\n\u6216\u8005\u53ef\u4ee5\u8fd9\u6837\uff1a\necho \"UUID=$(blkid \/dev\/sdb1 |cut -d'\"' -f2) \/data                 ext4    defaults        1 2\" >>\/etc\/fstab\n\n\n\u91cd\u542f\u7cfb\u7edf\uff1a\nreboot\n\n\n\nfstab\u4e2d\u7684\u5185\u5bb9\u89e3\u91ca\u8bf7\u53c2\u8003man\u4e2d\u7684\u5185\u5bb9\u3002\nThe first field, (fs_spec), describes the block special device or remote filesystem\n       to be mounted.\n       \u6307\u5b9a\u88ab\u6302\u8f7d\u7684\u8bbe\u5907\nThe second field, (fs_file), describes the mount point  for  the  filesystem.   For\n       swap partitions, this field should be specified as \u2018none\u2019. If the name of the mount\n       point contains spaces these can be escaped as \u2018\u000040\u2019.\n       \u6307\u5b9a\u6302\u8f7d\u70b9\nThe third field, (fs_vfstype), describes the type of the  filesystem. \n       \u6307\u5b9afs\u683c\u5f0f\nThe fourth  field,  (fs_mntops),  describes  the mount options associated with the\n       filesystem.     \n       \u6307\u5b9a\u6302\u8f7d\u9009\u9879\nThe fifth field, (fs_freq), is used for these filesystems by the dump(8) command to\n       determine  which filesystems need to be dumped.  If the fifth field is not present,\n       a value of zero is returned and dump will assume that the filesystem does not  need\n       to be dumped.\n       \u4f9bdump\u7528\nThe sixth field, (fs_passno), is used by the fsck(8) program to determine the order\n       in which filesystem checks are done at reboot time.  The root filesystem should  be\n       specified  with  a fs_passno of 1, and other filesystems should have a fs_passno of\n       2.  Filesystems within a drive will be checked  sequentially,  but  filesystems  on\n       different  drives will be checked at the same time to utilize parallelism available\n       in the hardware.  If the sixth field is not present or zero, a  value  of  zero  is\n       returned and fsck will assume that the filesystem does not need to be checked.\n       \u4f9bfsck\u7528\uff0croot\u662f1\uff0c\u5176\u4ed6\u7684fs\u662f2<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/dev\/disk\/by-id udevadm info -q symlink\u00a0-n \/dev\/sdb ude [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/1231"}],"collection":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1231"}],"version-history":[{"count":2,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/1231\/revisions"}],"predecessor-version":[{"id":2866,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/1231\/revisions\/2866"}],"wp:attachment":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}