Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

why i can't read sda1 with python?

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


1248283536 at qq

Jun 1, 2012, 7:14 PM

Post #1 of 4 (308 views)
Permalink
why i can't read sda1 with python?

tiger [at] debia:~$ sudo fdisk -l

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 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: 0x073a3c87

Device Boot Start End Blocks Id System
/dev/sda1 * 1 1912 15358108+ c W95 FAT32 (LBA)
/dev/sda2 1913 3736 14647296 b W95 FAT32
/dev/sda3 3736 3979 1952768 83 Linux
/dev/sda4 3979 14594 85260289 5 Extended
/dev/sda5 3979 4040 487424 83 Linux
/dev/sda6 4040 4769 5858304 83 Linux
/dev/sda7 4770 4891 975872 83 Linux
/dev/sda8 4891 5134 1951744 83 Linux
/dev/sda9 5134 14374 74217472 83 Linux
/dev/sda10 14374 14594 1764352 82 Linux swap / Solaris

i want to read sda1 with python:
>>> file=open('/dev/sda1','rb')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 13] Permission denied: '/dev/sda1'

how can i own the access to read sda1?


corey at octayn

Jun 4, 2012, 1:08 AM

Post #2 of 4 (299 views)
Permalink
Re: why i can't read sda1 with python? [In reply to]

On Sat, 2 Jun 2012 10:14:36 +0800
"水静流深" <1248283536 [at] qq> <1248283536 [at] qq> wrote:

> [snip]
> i want to read sda1 with python:
> >>> file=open('/dev/sda1','rb')
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> IOError: [Errno 13] Permission denied: '/dev/sda1'
>
> how can i own the access to read sda1?
>

You need read privileges. Either change the permissions of /dev/sda1,
or run python as root.

--
Corey Richardson
--
http://mail.python.org/mailman/listinfo/python-list


zhxia at njnet

Jun 4, 2012, 1:14 AM

Post #3 of 4 (300 views)
Permalink
Re: why i can't read sda1 with python? [In reply to]

#ls -l /dev/sda1
will print
brw-r----- 1 root disk ...
so only root or accounts in group disk can access /dev/sda1,
you could add the account into group disk with usermod, then re-login.

On Sat, 2 Jun 2012 10:14:36 +0800
"水静流深" <1248283536 [at] qq> wrote:

> tiger [at] debia:~$ sudo fdisk -l
>
> Disk /dev/sda: 120.0 GB, 120034123776 bytes
> 255 heads, 63 sectors/track, 14593 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: 0x073a3c87
>
> Device Boot Start End Blocks Id System
> /dev/sda1 * 1 1912 15358108+ c W95 FAT32 (LBA)
> /dev/sda2 1913 3736 14647296 b W95 FAT32
> /dev/sda3 3736 3979 1952768 83 Linux
> /dev/sda4 3979 14594 85260289 5 Extended
> /dev/sda5 3979 4040 487424 83 Linux
> /dev/sda6 4040 4769 5858304 83 Linux
> /dev/sda7 4770 4891 975872 83 Linux
> /dev/sda8 4891 5134 1951744 83 Linux
> /dev/sda9 5134 14374 74217472 83 Linux
> /dev/sda10 14374 14594 1764352 82 Linux swap / Solaris
>
> i want to read sda1 with python:
> >>> file=open('/dev/sda1','rb')
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> IOError: [Errno 13] Permission denied: '/dev/sda1'
>
> how can i own the access to read sda1?

--
http://mail.python.org/mailman/listinfo/python-list


mhrivnak at hrivnak

Jun 4, 2012, 10:16 PM

Post #4 of 4 (293 views)
Permalink
Re: why i can't read sda1 with python? [In reply to]

Which makes total sense. If any user could directly read the entire
contents of the disk, filesystem permissions would be useless.

Michael

On Mon, Jun 4, 2012 at 4:14 AM, Xia <zhxia [at] njnet> wrote:

> so only root or accounts in group disk can access /dev/sda1,
--
http://mail.python.org/mailman/listinfo/python-list

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.