Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to get and view uuid for ubuntu

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to get ubuntu to check uuid". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1, using UUID to identify the hard disk has many advantages, it is the only code name of a hard disk, so when the position of the hard disk socket changes, although sda may become sdc, this code will not change. So it may be confusing to use a hard drive such as / dev/sda1 in fstab. When one of the hard drives, such as sdb, dies, the sdc will become sdb,mount to the original sdb location. So you should still use UUID to write into fstab.

To get UUID, you can use this command.

The code is as follows:

Sudo blkid

2. Sometimes after reformatting a partition, the UUID will change. You can use this command to refresh the UUID.

The code is as follows:

Sudo blkid-s none

3, I wrote a piece of code, according to / dev/sda and other access to uuid, beginners to learn python, also written like this.

The code is as follows:

Def get_disk_uuid (disk):

Uuid =''

Cmd = 'sudo blkid'

Result = yitg_check_cmd_execute (cmd)

If (result [head]! = 0):

Return 0xACD

Res = result [BODY]

For i in range (0jinlen (res)):

Item = res [I]

Item_divide = item.split (':')

Item_zero = (item_divide [0])

If (disk! = item_zero):

Pass

Else:

Uuid_item = item_divide [1]

Uuid_divide = uuid_item.split ('"')

Uuid = uuid_divide [1]

Return uuid

Return uuid

One of the interface codes is as follows:

The code is as follows:

Def yitg_check_cmd_execute (cmd):

(os_result) = os.popen3 (cmd)

Res = os_result [1] .readlines ()

Error_res = os_result [2] .readlines ()

If (error_res):

Return send_msg (res, 0xABB)

Else:

Return send_msg (res, 0)

This is the end of the content of "how to get ubuntu to check uuid". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report