宝塔面板挂载到U盘(玩客云)

​ 前不久50元在🐟淘了个玩客云,之后有时间再介绍这东西,今天主要想记录下我挂载宝塔面板到U盘的过程😉

⏪ 前言:

玩客云作为主机只有8g的内部存储,如果安装宝塔到机身本来存储的话,随便部署点东西(或者安装点插件),内存就红了。第一反应我是删除某些没用的插件,结果还是杯水车薪 😔 。然后在CSDN上看到有人把硬盘挂载到玩客云上,我操作了一番,然后把网站部署到硬盘,然而结果也并没有变太好。然后寻找到了宝塔上的帖子,直接一不做二不休,先卸载宝塔,然后将U盘重新挂载,将宝塔安装到挂载的U盘。系统盘得到解放!:happy:

bt_memory.PNG

1️⃣ 基本准备:

无内容的U盘或者磁盘一个,插入已刷入Linux的玩客云主机,尽量插靠HDMI接口那个1口。然后玩客云接入家里的路由器。下个XSHELL到电脑,ssh到玩客云Linux系统。创建宝塔面板挂载目录/www:

1
mkdir -p /www

2️⃣ 格式化U盘及分区:

这里U盘需要格式化,如果觉得代码格盘麻烦,可以将U盘插到电脑,下载Dsikgenius来进行格式化。U盘需格式化为ext4格式。也可以用Linux命令进行格盘:

  • 输入 fdisk -l 查看所有硬盘分区及硬盘名 注意看最下面,Device boost start下方为你之前分区的盘的名字1,如我的是/dev/sda1

    bootstart.PNG

  • 输入以下代码对U盘进行格式化,其中/dev/sda为前面查看的U盘名

1
mkfs.ext4 /dev/sda
  • 然后等待格盘完成,格盘过程会出现如下代码:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    mke2fs 1.44.5 (15-Dec-2018)
    /dev/sda contains a ext4 file system
    last mounted on /mnt/diskyingpan on Mon Oct 24 10:57:48 2022
    Proceed anyway? (y,N) y#(这里需要自己输入y确认)#
    Creating filesystem with 7680000 4k blocks and 1921360 inodes
    Filesystem UUID: 14349e61-9865-4863-8157-fa9373f76f58
    Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
    4096000

    Allocating group tables: done
    Writing inode tables: done
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done #(这一步等待时间较长不要在这乱输入内容,等待即可)#
    done
  • 然后输入 fh -l查看格盘结果:注意看最下面的/dev/sda与/dev/mkblk0相比,/dev/sda后面代码没那么长

    格盘结果.PNG

  • 确认格盘成功后开始进行分区,输入:

    1
    fdisk /dev/sdb
  • 过程代码如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    Welcome to fdisk (util-linux 2.33.1).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.

    The old ext4 signature will be removed by a write command.

    Device does not contain a recognized partition table.
    Created a new DOS disklabel with disk identifier 0x37b2df98.

    Command (m for help): n#(这里输入n,继续)#
    Partition type
    p primary (0 primary, 0 extended, 4 free)
    e extended (container for logical partitions)
    Select (default p): p#(这里输入p继续)#
    Partition number (1-4, default 1): 1#(这里输入1继续)#
    First sector (2048-61439999, default 2048): #(不输入,直接回车)#
    Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-61439999, default 61439999): #(直接回车)#

    Created a new partition 1 of type 'Linux' and of size 29.3 GiB.

    Command (m for help): wq #输入wq#
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Syncing disks.

  • 检查分区情况:fdisk -l

  • 格式化分区:已格式化的可跳过这步,不过还是建议再格一下,过程和前面格盘差不多,但是代码注意填入分区名即图里面的 /dev/sda1

    1
    mkfs.ext4 /dev/sda1

3️⃣挂载及下载宝塔面板:

  • 将分区挂载信息添加到配置文件/etc/fstab中,实现开机/重启自动挂载:注意分区名不要打错了,我这是 /dev/sda1

    1
    echo "/dev/sda1 /www ext4 defaults 0 0" >> /etc/fstab
  • 重新挂载所有分区:

    1
    mount -a
  • 检查挂载是否成功:fh -l

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    Filesystem      Size  Used Avail Use% Mounted on
    udev 459M 0 459M 0% /dev
    tmpfs 99M 4.4M 95M 5% /run
    /dev/mmcblk0p2 6.5G 4.9G 1.7G 75% /
    tmpfs 495M 52K 495M 1% /dev/shm
    tmpfs 5.0M 0 5.0M 0% /run/lock
    tmpfs 495M 0 495M 0% /sys/fs/cgroup
    tmpfs 495M 20K 495M 1% /tmp
    /dev/mmcblk0p1 488M 49M 440M 10% /boot
    armbian-ramlog 50M 1.8M 49M 4% /var/log
    tmpfs 99M 0 99M 0% /run/user/0
    /dev/sda1 29G 45M 28G 1% /www #当你的挂载盘后边挂载信息为 /www时说明成功了#
  • 输入以下代码开始安装宝塔面板:

    1
    sudo apt-get install python-setuptools
    1
    wget -O install.sh http://download.bt.cn/install/install.sh && sh install.sh

    这里安装代码没有用宝塔面板的Debian推荐代码,我第一次使用官网的代码安装失败了,好像官网代码是安装最新的宝塔面板用的,但是玩客云推荐是宝塔5.9

  • 后面他会问你是否立即安装宝塔到/www地址,输入y继续:

    1
    Do you want to install Bt-Panel to the /www directory now?(y/n): y#这里输入y继续#

4️⃣ 漫长安装等待后,记下登录账号密码,进入浏览器输入网址就可访问了😁