Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to mount partition after losetup #7

Open
leslie-qiwa opened this issue Oct 18, 2022 · 2 comments · May be fixed by #8
Open

unable to mount partition after losetup #7

leslie-qiwa opened this issue Oct 18, 2022 · 2 comments · May be fixed by #8

Comments

@leslie-qiwa
Copy link

Thanks for the great package!

I use the example program to attach one device, but seems like unable to mount it. Can you help with it?

# losetup
NAME       SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE                DIO LOG-SEC
/dev/loop0         0      0         0  0 /tmp/deploy/newimage.img   0     512

# fdisk -l
Disk /dev/loop0: 4.9 GiB, 5242880000 bytes, 10240000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9f0032d8

Device       Boot   Start      End Sectors  Size Id Type
/dev/loop0p1 *       2048  2099199 2097152    1G 83 Linux
/dev/loop0p2      2099200  3123199 1024000  500M 82 Linux swap / Solaris
/dev/loop0p3      3123200 10239999 7116800  3.4G 83 Linux

# mount /dev/loop0p1 ./tt/
mount: /tmp/deploy/tt: special device /dev/loop0p1 does not exist.

@leslie-qiwa
Copy link
Author

example codes:

import (
        "fmt"
        "log"
        "os"

        "github.com/freddierice/go-losetup/v2"
)

func main() {
        // attach a raw file to a loop device
        dev, err := losetup.Attach(os.Args[1], 0, false)
        if err != nil {
                // error checking
                log.Fatal(err)
        }

        fmt.Printf("attached %s to %v\n", os.Args[1], dev.Path())

        /*
                err = dev.Detach()
                if err != nil {
                        // error checking
                        log.Fatal(err)
                }
        */
}

@leslie-qiwa
Copy link
Author

Seems like missing -P scan option. Maybe set it as default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant